update blocks data
This commit is contained in:
Binary file not shown.
Binary file not shown.
@ -44,8 +44,9 @@ var EntityList = [...]Entity{
|
||||
ChiseledBookshelfEntity{},
|
||||
BrushableBlockEntity{},
|
||||
DecoratedPotEntity{},
|
||||
// CrafterEntity{},
|
||||
// TrialSpawnerEntity{},
|
||||
CrafterEntity{},
|
||||
TrialSpawnerEntity{},
|
||||
VaultEntity{},
|
||||
}
|
||||
|
||||
func (FurnaceEntity) ID() string { return "minecraft:furnace" }
|
||||
@ -89,9 +90,9 @@ func (SculkShriekerEntity) ID() string { return "minecraft:sculk_shrieke
|
||||
func (ChiseledBookshelfEntity) ID() string { return "minecraft:chiseled_bookshelf" }
|
||||
func (BrushableBlockEntity) ID() string { return "minecraft:brushable_block" }
|
||||
func (DecoratedPotEntity) ID() string { return "minecraft:decorated_pot" }
|
||||
|
||||
// func (CrafterEntity) ID() string { return "minecraft:crafter" }
|
||||
// func (TrialSpawnerEntity) ID() string { return "minecraft:trial_spawner" }
|
||||
func (CrafterEntity) ID() string { return "minecraft:crafter" }
|
||||
func (TrialSpawnerEntity) ID() string { return "minecraft:trial_spawner" }
|
||||
func (VaultEntity) ID() string { return "minecraft:vault" }
|
||||
|
||||
func (f FurnaceEntity) IsValidBlock(block Block) bool {
|
||||
return block.ID() == "minecraft:furnace"
|
||||
@ -429,10 +430,14 @@ func (d DecoratedPotEntity) IsValidBlock(block Block) bool {
|
||||
return block.ID() == "minecraft:decorated_pot"
|
||||
}
|
||||
|
||||
// func (c CrafterEntity) IsValidBlock(block Block) bool {
|
||||
// return block.ID() == "minecraft:crafter"
|
||||
// }
|
||||
//
|
||||
// func (t TrialSpawnerEntity) IsValidBlock(block Block) bool {
|
||||
// return block.ID() == "minecraft:trial_spawner"
|
||||
// }
|
||||
func (c CrafterEntity) IsValidBlock(block Block) bool {
|
||||
return block.ID() == "minecraft:crafter"
|
||||
}
|
||||
|
||||
func (t TrialSpawnerEntity) IsValidBlock(block Block) bool {
|
||||
return block.ID() == "minecraft:trial_spawner"
|
||||
}
|
||||
|
||||
func (v VaultEntity) IsValidBlock(block Block) bool {
|
||||
return block.ID() == "minecraft:vault"
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ type (
|
||||
SuspiciousSandEntity struct{}
|
||||
BrushableBlockEntity struct{}
|
||||
DecoratedPotEntity struct{}
|
||||
CrafterEntity struct{}
|
||||
TrialSpawnerEntity struct{}
|
||||
VaultEntity struct{}
|
||||
)
|
||||
|
||||
type EntityType int32
|
||||
|
@ -3452,8 +3452,17 @@ type (
|
||||
Triggered Boolean `nbt:"triggered"`
|
||||
}
|
||||
TrialSpawner struct {
|
||||
Ominous Boolean `nbt:"ominous"`
|
||||
Trial_spawner_state TrialSpawnerState `nbt:"trial_spawner_state"`
|
||||
}
|
||||
Vault struct {
|
||||
Facing Direction `nbt:"facing"`
|
||||
Ominous Boolean `nbt:"ominous"`
|
||||
Vault_state VaultState `nbt:"vault_state"`
|
||||
}
|
||||
HeavyCore struct {
|
||||
Waterlogged Boolean `nbt:"waterlogged"`
|
||||
}
|
||||
)
|
||||
|
||||
func (Air) ID() string { return "minecraft:air" }
|
||||
@ -4520,6 +4529,8 @@ func (ReinforcedDeepslate) ID() string { return "minecraft:reinforced_d
|
||||
func (DecoratedPot) ID() string { return "minecraft:decorated_pot" }
|
||||
func (Crafter) ID() string { return "minecraft:crafter" }
|
||||
func (TrialSpawner) ID() string { return "minecraft:trial_spawner" }
|
||||
func (Vault) ID() string { return "minecraft:vault" }
|
||||
func (HeavyCore) ID() string { return "minecraft:heavy_core" }
|
||||
|
||||
var FromID = map[string]Block{
|
||||
"minecraft:air": Air{},
|
||||
@ -5580,4 +5591,6 @@ var FromID = map[string]Block{
|
||||
"minecraft:decorated_pot": DecoratedPot{},
|
||||
"minecraft:crafter": Crafter{},
|
||||
"minecraft:trial_spawner": TrialSpawner{},
|
||||
"minecraft:vault": Vault{},
|
||||
"minecraft:heavy_core": HeavyCore{},
|
||||
}
|
||||
|
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
package pers.tnze.gomc.gen;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.*;
|
||||
@ -16,8 +15,10 @@ import net.minecraft.world.level.block.state.properties.Property;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class GenBlocks {
|
||||
@ -54,26 +55,14 @@ public class GenBlocks {
|
||||
BlockState state = block.defaultBlockState();
|
||||
CompoundTag b = new CompoundTag();
|
||||
b.putString("Name", BuiltInRegistries.BLOCK.getKey(block).toString());
|
||||
ImmutableMap<Property<?>, Comparable<?>> values = state.getValues();
|
||||
Map<Property<?>, Comparable<?>> values = state.getValues();
|
||||
if (!values.isEmpty()) {
|
||||
CompoundTag meta = new CompoundTag();
|
||||
for (Map.Entry<Property<?>, Comparable<?>> entry : values.entrySet()) {
|
||||
Property<?> key = entry.getKey();
|
||||
Comparable<?> value = entry.getValue();
|
||||
String name = key.getName();
|
||||
String typeName;
|
||||
if (key instanceof EnumProperty<?>) {
|
||||
if (value.getClass().getName().contains("net.minecraft.core.Direction$Axis")) {
|
||||
typeName = "Axis";
|
||||
} else {
|
||||
typeName = value.getClass().getSimpleName();
|
||||
}
|
||||
if (typeName.isBlank()) {
|
||||
throw new Exception("Type is blank: " + value.getClass().getName());
|
||||
}
|
||||
} else {
|
||||
typeName = key.getClass().getSimpleName();
|
||||
}
|
||||
String typeName = getTypeName(key, value);
|
||||
meta.putString(name, typeName);
|
||||
}
|
||||
b.put("Meta", meta);
|
||||
@ -83,6 +72,26 @@ public class GenBlocks {
|
||||
return list;
|
||||
}
|
||||
|
||||
private static String getTypeName(Property<?> key, Comparable<?> value) throws Exception {
|
||||
String typeName;
|
||||
if (key instanceof EnumProperty<?>) {
|
||||
Class<?> clazz = value.getClass();
|
||||
if (clazz.getName().contains("net.minecraft.core.Direction$Axis")) {
|
||||
typeName = "Axis";
|
||||
} else if(clazz.getName().contains("net.minecraft.world.level.block.entity.vault.VaultState")) {
|
||||
typeName = "VaultState";
|
||||
} else {
|
||||
typeName = clazz.getSimpleName();
|
||||
}
|
||||
if (typeName.isBlank()) {
|
||||
throw new Exception("Type is blank: " + clazz.getName());
|
||||
}
|
||||
} else {
|
||||
typeName = key.getClass().getSimpleName();
|
||||
}
|
||||
return typeName;
|
||||
}
|
||||
|
||||
private static ListTag getBlockStates() {
|
||||
ListTag list = new ListTag();
|
||||
for (BlockState blockState : Block.BLOCK_STATE_REGISTRY) {
|
||||
@ -93,10 +102,26 @@ public class GenBlocks {
|
||||
|
||||
private static ListTag genBlockEntities() {
|
||||
ListTag list = new ListTag();
|
||||
Field validBlocksField;
|
||||
try {
|
||||
validBlocksField = BlockEntityType.class.getDeclaredField("validBlocks");
|
||||
validBlocksField.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
for (BlockEntityType<?> blockEntity : BuiltInRegistries.BLOCK_ENTITY_TYPE) {
|
||||
ResourceLocation value = BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(blockEntity);
|
||||
ListTag validBlocksList = new ListTag();
|
||||
for (Block validBlock : blockEntity.validBlocks){
|
||||
|
||||
Set<Block> validBlocks;
|
||||
try {
|
||||
Object validBlocksObj = validBlocksField.get(blockEntity);
|
||||
validBlocks = (Set<Block>) validBlocksObj;
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (Block validBlock : validBlocks){
|
||||
validBlocksList.add(StringTag.valueOf(BuiltInRegistries.BLOCK.getKey(validBlock).toString()));
|
||||
}
|
||||
CompoundTag be = new CompoundTag();
|
||||
|
@ -54,6 +54,10 @@ var EnumProperties = []EnumProperty{
|
||||
"up_east", "up_north", "up_south", "up_west",
|
||||
"west_up", "east_up", "north_up", "south_up",
|
||||
}},
|
||||
{Name: "VaultState", Values: []string{"inactive", "active", "unlocking", "ejecting"}},
|
||||
{Name: "TrialSpawnerState", Values: []string{
|
||||
"inactive", "waiting_for_players", "active", "waiting_for_reward_ejection", "ejecting_reward", "cooldown",
|
||||
}},
|
||||
}
|
||||
|
||||
//go:embed properties_enum.go.tmpl
|
||||
|
@ -1001,13 +1001,90 @@ func (f *FrontAndTop) UnmarshalText(text []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type TrialSpawnerState = string
|
||||
type VaultState byte
|
||||
|
||||
const (
|
||||
TrailSpawnerActive = "active"
|
||||
TrailSpawnerCooldown = "cooldown"
|
||||
TrailSpawnerEjectingReward = "ejecting_reward"
|
||||
TrailSpawnerInactive = "inactive"
|
||||
TrailSpawnerWaitingForPlayers = "waiting_for_players"
|
||||
TrailSpawnerWaitingForRewardEjection = "waiting_for_reward_ejection"
|
||||
VaultStateInactive VaultState = iota
|
||||
VaultStateActive
|
||||
VaultStateUnlocking
|
||||
VaultStateEjecting
|
||||
)
|
||||
|
||||
var strVaultState = [...]string{"inactive", "active", "unlocking", "ejecting"}
|
||||
|
||||
func (v VaultState) String() string {
|
||||
if int(v) < len(strVaultState) {
|
||||
return strVaultState[v]
|
||||
}
|
||||
return "invalid VaultState"
|
||||
}
|
||||
|
||||
func (v VaultState) MarshalText() (text []byte, err error) {
|
||||
if int(v) < len(strVaultState) {
|
||||
return []byte(strVaultState[v]), nil
|
||||
}
|
||||
return nil, errors.New("invalid VaultState: " + strconv.Itoa(int(v)))
|
||||
}
|
||||
|
||||
func (v *VaultState) UnmarshalText(text []byte) error {
|
||||
switch str := string(text); str {
|
||||
case "inactive":
|
||||
*v = VaultStateInactive
|
||||
case "active":
|
||||
*v = VaultStateActive
|
||||
case "unlocking":
|
||||
*v = VaultStateUnlocking
|
||||
case "ejecting":
|
||||
*v = VaultStateEjecting
|
||||
default:
|
||||
return errors.New("unknown VaultState: " + str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type TrialSpawnerState byte
|
||||
|
||||
const (
|
||||
TrialSpawnerStateInactive TrialSpawnerState = iota
|
||||
TrialSpawnerStateWaitingForPlayers
|
||||
TrialSpawnerStateActive
|
||||
TrialSpawnerStateWaitingForRewardEjection
|
||||
TrialSpawnerStateEjectingReward
|
||||
TrialSpawnerStateCooldown
|
||||
)
|
||||
|
||||
var strTrialSpawnerState = [...]string{"inactive", "waiting_for_players", "active", "waiting_for_reward_ejection", "ejecting_reward", "cooldown"}
|
||||
|
||||
func (t TrialSpawnerState) String() string {
|
||||
if int(t) < len(strTrialSpawnerState) {
|
||||
return strTrialSpawnerState[t]
|
||||
}
|
||||
return "invalid TrialSpawnerState"
|
||||
}
|
||||
|
||||
func (t TrialSpawnerState) MarshalText() (text []byte, err error) {
|
||||
if int(t) < len(strTrialSpawnerState) {
|
||||
return []byte(strTrialSpawnerState[t]), nil
|
||||
}
|
||||
return nil, errors.New("invalid TrialSpawnerState: " + strconv.Itoa(int(t)))
|
||||
}
|
||||
|
||||
func (t *TrialSpawnerState) UnmarshalText(text []byte) error {
|
||||
switch str := string(text); str {
|
||||
case "inactive":
|
||||
*t = TrialSpawnerStateInactive
|
||||
case "waiting_for_players":
|
||||
*t = TrialSpawnerStateWaitingForPlayers
|
||||
case "active":
|
||||
*t = TrialSpawnerStateActive
|
||||
case "waiting_for_reward_ejection":
|
||||
*t = TrialSpawnerStateWaitingForRewardEjection
|
||||
case "ejecting_reward":
|
||||
*t = TrialSpawnerStateEjectingReward
|
||||
case "cooldown":
|
||||
*t = TrialSpawnerStateCooldown
|
||||
default:
|
||||
return errors.New("unknown TrialSpawnerState: " + str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user