mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -04:00
Generify mod and identifier holder into ModIdentifier
This commit is contained in:
parent
f44cf53268
commit
a0b7bdeeee
@ -13,17 +13,13 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings;
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
public record BlockId(String mod, String identifier) {
|
public class BlockId extends ModIdentifier {
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
public BlockId(String mod, String identifier) {
|
||||||
|
super(mod, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public BlockId(String fullIdentifier) {
|
||||||
return identifier;
|
super(fullIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", getMod(), getIdentifier());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,39 +13,18 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings;
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
public class Dimension {
|
public class Dimension extends ModIdentifier {
|
||||||
final String mod;
|
|
||||||
final String identifier;
|
|
||||||
final boolean hasSkyLight;
|
final boolean hasSkyLight;
|
||||||
|
|
||||||
public Dimension(String mod, String identifier, boolean hasSkyLight) {
|
public Dimension(String mod, String identifier, boolean hasSkyLight) {
|
||||||
this.mod = mod;
|
super(mod, identifier);
|
||||||
this.identifier = identifier;
|
|
||||||
this.hasSkyLight = hasSkyLight;
|
this.hasSkyLight = hasSkyLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdentifier() {
|
|
||||||
return identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSkyLight() {
|
public boolean hasSkyLight() {
|
||||||
return hasSkyLight;
|
return hasSkyLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", getMod(), getIdentifier());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return mod.hashCode() * identifier.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (super.equals(obj)) {
|
if (super.equals(obj)) {
|
||||||
|
@ -13,17 +13,13 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings;
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
public record Enchantment(String mod, String identifier) {
|
public class Enchantment extends ModIdentifier {
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
public Enchantment(String mod, String identifier) {
|
||||||
|
super(mod, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public Enchantment(String fullIdentifier) {
|
||||||
return identifier;
|
super(fullIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", mod, identifier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,48 +13,13 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings;
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
public class Item {
|
public class Item extends ModIdentifier {
|
||||||
final String mod;
|
|
||||||
final String identifier;
|
|
||||||
|
|
||||||
public Item(String fullIdentifier) {
|
public Item(String fullIdentifier) {
|
||||||
String[] split = fullIdentifier.split(":");
|
super(fullIdentifier);
|
||||||
this.mod = split[0];
|
|
||||||
this.identifier = split[1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item(String mod, String identifier) {
|
public Item(String mod, String identifier) {
|
||||||
this.mod = mod;
|
super(mod, identifier);
|
||||||
this.identifier = identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdentifier() {
|
|
||||||
return identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", getMod(), getIdentifier());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return mod.hashCode() * identifier.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if (super.equals(obj)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (hashCode() != obj.hashCode()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Item their = (Item) obj;
|
|
||||||
return getIdentifier().equals(their.getIdentifier()) && getMod().equals(their.getMod());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,13 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings;
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
public record MobEffect(String mod, String identifier) {
|
public class MobEffect extends ModIdentifier {
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
public MobEffect(String mod, String identifier) {
|
||||||
|
super(mod, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public MobEffect(String fullIdentifier) {
|
||||||
return identifier;
|
super(fullIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", getMod(), getIdentifier());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
|
public class ModIdentifier {
|
||||||
|
public static final String DEFAULT_MOD = "minecraft";
|
||||||
|
protected final String mod;
|
||||||
|
protected final String identifier;
|
||||||
|
|
||||||
|
public ModIdentifier(String mod, String identifier) {
|
||||||
|
this.mod = mod;
|
||||||
|
this.identifier = identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModIdentifier(String fullIdentifier) {
|
||||||
|
String[] split = fullIdentifier.split(":");
|
||||||
|
if (split.length == 1) {
|
||||||
|
this.mod = DEFAULT_MOD;
|
||||||
|
this.identifier = fullIdentifier;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.mod = split[0];
|
||||||
|
this.identifier = split[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMod() {
|
||||||
|
return mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIdentifier() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return String.format("%s:%s", mod, identifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return mod.hashCode() * identifier.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (super.equals(obj)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (hashCode() != obj.hashCode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Item their = (Item) obj;
|
||||||
|
return getIdentifier().equals(their.getIdentifier()) && getMod().equals(their.getMod());
|
||||||
|
}
|
||||||
|
}
|
@ -13,17 +13,13 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings;
|
package de.bixilon.minosoft.data.mappings;
|
||||||
|
|
||||||
public record Motive(String mod, String identifier) {
|
public class Motive extends ModIdentifier {
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
public Motive(String mod, String identifier) {
|
||||||
|
super(mod, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public Motive(String fullIdentifier) {
|
||||||
return identifier;
|
super(fullIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", getMod(), getIdentifier());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,50 +13,38 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings.blocks;
|
package de.bixilon.minosoft.data.mappings.blocks;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.mappings.ModIdentifier;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class Block {
|
public class Block extends ModIdentifier {
|
||||||
final String mod;
|
|
||||||
final String identifier;
|
|
||||||
final BlockRotations rotation;
|
final BlockRotations rotation;
|
||||||
final HashSet<BlockProperties> properties;
|
final HashSet<BlockProperties> properties;
|
||||||
|
|
||||||
public Block(String mod, String identifier, HashSet<BlockProperties> properties, BlockRotations rotation) {
|
public Block(String mod, String identifier, HashSet<BlockProperties> properties, BlockRotations rotation) {
|
||||||
this.mod = mod;
|
super(mod, identifier);
|
||||||
this.identifier = identifier;
|
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block(String mod, String identifier, HashSet<BlockProperties> properties) {
|
public Block(String mod, String identifier, HashSet<BlockProperties> properties) {
|
||||||
this.mod = mod;
|
super(mod, identifier);
|
||||||
this.identifier = identifier;
|
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.rotation = BlockRotations.NONE;
|
this.rotation = BlockRotations.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block(String mod, String identifier, BlockRotations rotation) {
|
public Block(String mod, String identifier, BlockRotations rotation) {
|
||||||
this.mod = mod;
|
super(mod, identifier);
|
||||||
this.identifier = identifier;
|
|
||||||
this.properties = new HashSet<>();
|
this.properties = new HashSet<>();
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block(String mod, String identifier) {
|
public Block(String mod, String identifier) {
|
||||||
this.mod = mod;
|
super(mod, identifier);
|
||||||
this.identifier = identifier;
|
|
||||||
this.properties = new HashSet<>();
|
this.properties = new HashSet<>();
|
||||||
this.rotation = BlockRotations.NONE;
|
this.rotation = BlockRotations.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdentifier() {
|
|
||||||
return identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockRotations getRotation() {
|
public BlockRotations getRotation() {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,15 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings.particle;
|
package de.bixilon.minosoft.data.mappings.particle;
|
||||||
|
|
||||||
public record Particle(String mod, String identifier) {
|
import de.bixilon.minosoft.data.mappings.ModIdentifier;
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
public class Particle extends ModIdentifier {
|
||||||
|
|
||||||
|
public Particle(String mod, String identifier) {
|
||||||
|
super(mod, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public Particle(String fullIdentifier) {
|
||||||
return identifier;
|
super(fullIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", mod, identifier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,17 +13,15 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.mappings.statistics;
|
package de.bixilon.minosoft.data.mappings.statistics;
|
||||||
|
|
||||||
public record Statistic(String mod, String identifier) {
|
import de.bixilon.minosoft.data.mappings.ModIdentifier;
|
||||||
public String getMod() {
|
|
||||||
return mod;
|
public class Statistic extends ModIdentifier {
|
||||||
|
|
||||||
|
public Statistic(String mod, String identifier) {
|
||||||
|
super(mod, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier() {
|
public Statistic(String fullIdentifier) {
|
||||||
return identifier;
|
super(fullIdentifier);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("%s:%s", mod, identifier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user