forked from retrooper/packetevents
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish refactoring and fixing entity data types
- Loading branch information
Showing
18 changed files
with
721 additions
and
217 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
api/src/main/java/com/github/retrooper/packetevents/protocol/entity/cat/CatVariant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
api/src/main/java/com/github/retrooper/packetevents/protocol/entity/cat/CatVariantImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
api/src/main/java/com/github/retrooper/packetevents/protocol/entity/cat/CatVariants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.