Skip to content

Commit

Permalink
Finish refactoring and fixing entity data types
Browse files Browse the repository at this point in the history
  • Loading branch information
booky10 committed Nov 26, 2024
1 parent 025fac7 commit 9e19aad
Show file tree
Hide file tree
Showing 18 changed files with 721 additions and 217 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2024 retrooper 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.github.retrooper.packetevents.protocol.entity.cat;

import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;

public interface CatVariant extends MappedEntity {

ResourceLocation getTexture();

static CatVariant read(PacketWrapper<?> wrapper) {
return wrapper.readMappedEntity(CatVariants.getRegistry());
}

static void write(PacketWrapper<?> wrapper, CatVariant variant) {
wrapper.writeMappedEntity(variant);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2024 retrooper 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.github.retrooper.packetevents.protocol.entity.cat;

import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;

public class CatVariantImpl extends AbstractMappedEntity implements CatVariant {

private final ResourceLocation texture;

public CatVariantImpl(TypesBuilderData data, ResourceLocation texture) {
super(data);
this.texture = texture;
}

@Override
public ResourceLocation getTexture() {
return this.texture;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2024 retrooper 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.github.retrooper.packetevents.protocol.entity.cat;

import com.github.retrooper.packetevents.resources.ResourceLocation;
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;

public final class CatVariants {

private static final VersionedRegistry<CatVariant> REGISTRY = new VersionedRegistry<>(
"cat_variant", "entity/cat_variant_mappings");

public static final CatVariant TABBY = define("tabby");
public static final CatVariant BLACK = define("black");
public static final CatVariant RED = define("red");
public static final CatVariant SIAMESE = define("siamese");
public static final CatVariant BRITISH_SHORTHAIR = define("british_shorthair");
public static final CatVariant CALICO = define("calico");
public static final CatVariant PERSIAN = define("persian");
public static final CatVariant RAGDOLL = define("ragdoll");
public static final CatVariant WHITE = define("white");
public static final CatVariant JELLIE = define("jellie");
public static final CatVariant ALL_BLACK = define("all_black");

private CatVariants() {
}

private static CatVariant define(String name) {
return define(name, ResourceLocation.minecraft("textures/entity/cat/" + name + ".png"));
}

private static CatVariant define(String name, ResourceLocation texture) {
return REGISTRY.define(name, data -> new CatVariantImpl(data, texture));
}

public static VersionedRegistry<CatVariant> getRegistry() {
return REGISTRY;
}

static {
REGISTRY.unloadMappings();
}
}
Loading

0 comments on commit 9e19aad

Please sign in to comment.