Skip to content

Commit 9e19aad

Browse files
committed
Finish refactoring and fixing entity data types
1 parent 025fac7 commit 9e19aad

File tree

18 files changed

+721
-217
lines changed

18 files changed

+721
-217
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file is part of packetevents - https://github.com/retrooper/packetevents
3+
* Copyright (C) 2024 retrooper and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package com.github.retrooper.packetevents.protocol.entity.cat;
20+
21+
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
22+
import com.github.retrooper.packetevents.resources.ResourceLocation;
23+
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
24+
25+
public interface CatVariant extends MappedEntity {
26+
27+
ResourceLocation getTexture();
28+
29+
static CatVariant read(PacketWrapper<?> wrapper) {
30+
return wrapper.readMappedEntity(CatVariants.getRegistry());
31+
}
32+
33+
static void write(PacketWrapper<?> wrapper, CatVariant variant) {
34+
wrapper.writeMappedEntity(variant);
35+
}
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of packetevents - https://github.com/retrooper/packetevents
3+
* Copyright (C) 2024 retrooper and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package com.github.retrooper.packetevents.protocol.entity.cat;
20+
21+
import com.github.retrooper.packetevents.protocol.mapper.AbstractMappedEntity;
22+
import com.github.retrooper.packetevents.resources.ResourceLocation;
23+
import com.github.retrooper.packetevents.util.mappings.TypesBuilderData;
24+
25+
public class CatVariantImpl extends AbstractMappedEntity implements CatVariant {
26+
27+
private final ResourceLocation texture;
28+
29+
public CatVariantImpl(TypesBuilderData data, ResourceLocation texture) {
30+
super(data);
31+
this.texture = texture;
32+
}
33+
34+
@Override
35+
public ResourceLocation getTexture() {
36+
return this.texture;
37+
}
38+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This file is part of packetevents - https://github.com/retrooper/packetevents
3+
* Copyright (C) 2024 retrooper and contributors
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package com.github.retrooper.packetevents.protocol.entity.cat;
20+
21+
import com.github.retrooper.packetevents.resources.ResourceLocation;
22+
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
23+
24+
public final class CatVariants {
25+
26+
private static final VersionedRegistry<CatVariant> REGISTRY = new VersionedRegistry<>(
27+
"cat_variant", "entity/cat_variant_mappings");
28+
29+
public static final CatVariant TABBY = define("tabby");
30+
public static final CatVariant BLACK = define("black");
31+
public static final CatVariant RED = define("red");
32+
public static final CatVariant SIAMESE = define("siamese");
33+
public static final CatVariant BRITISH_SHORTHAIR = define("british_shorthair");
34+
public static final CatVariant CALICO = define("calico");
35+
public static final CatVariant PERSIAN = define("persian");
36+
public static final CatVariant RAGDOLL = define("ragdoll");
37+
public static final CatVariant WHITE = define("white");
38+
public static final CatVariant JELLIE = define("jellie");
39+
public static final CatVariant ALL_BLACK = define("all_black");
40+
41+
private CatVariants() {
42+
}
43+
44+
private static CatVariant define(String name) {
45+
return define(name, ResourceLocation.minecraft("textures/entity/cat/" + name + ".png"));
46+
}
47+
48+
private static CatVariant define(String name, ResourceLocation texture) {
49+
return REGISTRY.define(name, data -> new CatVariantImpl(data, texture));
50+
}
51+
52+
public static VersionedRegistry<CatVariant> getRegistry() {
53+
return REGISTRY;
54+
}
55+
56+
static {
57+
REGISTRY.unloadMappings();
58+
}
59+
}

0 commit comments

Comments
 (0)