Skip to content

Commit

Permalink
Merge pull request #890 from booky10/fix/null-material-types
Browse files Browse the repository at this point in the history
Fix missing material types for vault and heavy core
  • Loading branch information
retrooper authored Jul 12, 2024
2 parents 7ceeaa5 + 25dfb3c commit 245ee76
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,8 @@ public static StateType.Mapped getMappedById(ClientVersion version, int id) {
public static StateType TRIAL_SPAWNER = StateTypes.builder().name("TRIAL_SPAWNER").blastResistance(50.0f).hardness(50.0f).isBlocking(true).requiresCorrectTool(true).isSolid(true).setMaterial(MaterialType.STONE).build();

// 1.20.5 added types
public static StateType VAULT = StateTypes.builder().name("vault").blastResistance(50.0f).hardness(50.0f).isBlocking(true).requiresCorrectTool(true).isSolid(true).build();
public static StateType HEAVY_CORE = StateTypes.builder().name("heavy_core").blastResistance(1200.0f).hardness(10.0f).isBlocking(true).requiresCorrectTool(false).isSolid(false).build();
public static StateType VAULT = StateTypes.builder().name("vault").blastResistance(50.0f).hardness(50.0f).isBlocking(true).requiresCorrectTool(true).isSolid(true).setMaterial(MaterialType.STONE).build();
public static StateType HEAVY_CORE = StateTypes.builder().name("heavy_core").blastResistance(1200.0f).hardness(10.0f).isBlocking(true).requiresCorrectTool(false).isSolid(false).setMaterial(MaterialType.METAL).build();

static {
TYPES_BUILDER.unloadFileMappings();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.test;

import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.test.base.BaseDummyAPITest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class EnsureValidStateTypesTest extends BaseDummyAPITest {

@Test
@DisplayName("Verify non-null material type")
public void testStateTypesMaterialType() {
for (StateType stateType : StateTypes.values()) {
assertNotNull(stateType.getMaterialType(),
() -> stateType.getName() + " has no material type");
}
}
}

0 comments on commit 245ee76

Please sign in to comment.