3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-11-20 06:50:10 +01:00

Store Parrot tamed data

Dieser Commit ist enthalten in:
Matsv 2017-06-13 16:32:43 +02:00
Ursprung 354660a374
Commit ce89d1c724
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
2 geänderte Dateien mit 38 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,19 @@
/*
* Copyright (c) 2016 Matsv
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
import lombok.Data;
import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
@Data
public class ParrotStorage extends EntityStorage {
private boolean tamed = true;
}

Datei anzeigen

@ -15,8 +15,10 @@ import nl.matsv.viabackwards.api.entities.storage.EntityData;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage; import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType; import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
import nl.matsv.viabackwards.api.entities.types.EntityType1_12; import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter; import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12; import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.ParrotStorage;
import nl.matsv.viabackwards.utils.Block; import nl.matsv.viabackwards.utils.Block;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
@ -368,9 +370,25 @@ public class EntityPackets1_12 extends EntityRewriter<Protocol1_11_1To1_12> {
registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, true, 12).removed(); registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, true, 12).removed();
registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, true, 13).handleIndexChange(12); registerMetaHandler().filter(EntityType.EVOCATION_ILLAGER, true, 13).handleIndexChange(12);
// Create Parrot storage
registerMetaHandler().filter(EntityType.PARROT, true).handle(e -> {
if (!e.getEntity().has(ParrotStorage.class))
e.getEntity().put(new ParrotStorage());
return e.getData();
});
// Parrot remove animal metadata // Parrot remove animal metadata
registerMetaHandler().filter(EntityType.PARROT, 12).removed(); // Is baby registerMetaHandler().filter(EntityType.PARROT, 12).removed(); // Is baby
registerMetaHandler().filter(EntityType.PARROT, 13).removed(); // Flags (Is sitting etc, might be useful in the future (bat inactive TODO do more research about this entity) registerMetaHandler().filter(EntityType.PARROT, 13).handle(e -> {
ParrotStorage storage = e.getEntity().get(ParrotStorage.class);
boolean isTamed = (((byte) e.getData().getValue()) & 0x04) == 0x04;
if (!storage.isTamed() && isTamed) {
// TODO do something to let the user know it's done
}
storage.setTamed(isTamed);
throw new RemovedValueException();
}); // Flags (Is sitting etc, might be useful in the future
registerMetaHandler().filter(EntityType.PARROT, 14).removed(); // Owner registerMetaHandler().filter(EntityType.PARROT, 14).removed(); // Owner
registerMetaHandler().filter(EntityType.PARROT, 15).removed(); // Variant registerMetaHandler().filter(EntityType.PARROT, 15).removed(); // Variant