64 lines
2.5 KiB
Java
64 lines
2.5 KiB
Java
/*
|
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
|
* Copyright (C) 2016-2021 ViaVersion and contributors
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package com.viaversion.viaversion.protocols.protocol1_12to1_11_1.metadata;
|
|
|
|
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_12Types;
|
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|
import com.viaversion.viaversion.rewriter.MetadataRewriter;
|
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.BedRewriter;
|
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
|
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.storage.EntityTracker1_12;
|
|
|
|
import java.util.List;
|
|
|
|
public class MetadataRewriter1_12To1_11_1 extends MetadataRewriter {
|
|
|
|
public MetadataRewriter1_12To1_11_1(Protocol1_12To1_11_1 protocol) {
|
|
super(protocol, EntityTracker1_12.class);
|
|
}
|
|
|
|
@Override
|
|
protected void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) {
|
|
if (metadata.getValue() instanceof Item) {
|
|
// Apply rewrite
|
|
BedRewriter.toClientItem((Item) metadata.getValue());
|
|
}
|
|
|
|
if (type == null) return;
|
|
// Evocation Illager aggressive property became 13
|
|
if (type == Entity1_12Types.EntityType.EVOCATION_ILLAGER) {
|
|
if (metadata.getId() == 12) {
|
|
metadata.setId(13);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected EntityType getTypeFromId(int type) {
|
|
return Entity1_12Types.getTypeFromId(type, false);
|
|
}
|
|
|
|
@Override
|
|
protected EntityType getObjectTypeFromId(int type) {
|
|
return Entity1_12Types.getTypeFromId(type, true);
|
|
}
|
|
}
|