Skip to content

Commit

Permalink
Allowed Thermoregulators to be rotated horizontally
Browse files Browse the repository at this point in the history
  • Loading branch information
Forstride committed Jan 4, 2024
1 parent b50a443 commit 8bccb2c
Show file tree
Hide file tree
Showing 16 changed files with 110 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-01-04T08:50:20.0019248 Tags for minecraft:item mod id toughasnails
// 1.20.4 2024-01-04T15:02:33.4878204 Tags for minecraft:item mod id toughasnails
f05342856fe99891fa5e94bbe8db82a4f75ac41e data/toughasnails/tags/items/cooling_armor.json
572f6d0748095755aeef0ca7d602f4ebba9bfd76 data/toughasnails/tags/items/cooling_consumed_items.json
7c304628a9c17ca3ba6cd13e199fcf73ad9c974f data/toughasnails/tags/items/cooling_held_items.json
Expand All @@ -21,7 +21,7 @@ f87a1c4dc42b16f1628cfca591895d987e5dc6ca data/toughasnails/tags/items/poison_cha
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/toughasnails/tags/items/poison_chance/50_poison_chance_drinks.json
cc0aa3bf437ed849deda4e4b64aff3665160dae6 data/toughasnails/tags/items/poison_chance/75_poison_chance_drinks.json
6f524ffe3a9819336fb57316d3245695a9601368 data/toughasnails/tags/items/thermoregulator_cooling_fuel.json
3d80c1a95b23a8f6e2e0350454fc36e0743ee45a data/toughasnails/tags/items/thermoregulator_heating_fuel.json
0a899c9faf8d9ae947deb0268aa08dbcff8ecdf1 data/toughasnails/tags/items/thermoregulator_heating_fuel.json
0395ed7d6e3d7510a25d2f4ef8b498b0d8c6c9eb data/toughasnails/tags/items/thirst/10_thirst_drinks.json
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/toughasnails/tags/items/thirst/11_thirst_drinks.json
35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/toughasnails/tags/items/thirst/12_thirst_drinks.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-01-04T10:16:03.4651007 Recipes
// 1.20.4 2024-01-04T15:52:05.5413549 Recipes
09252bd5a872203de304820e8d5c5493afe96cf4 data/toughasnails/advancements/recipes/combat/leaf_boots.json
2da825265e95f5dfc0dd4026e0dafee70c17512c data/toughasnails/advancements/recipes/combat/leaf_chestplate.json
6d96cd4baff66d426c9405852ceed3aa8a3cde8f data/toughasnails/advancements/recipes/combat/leaf_helmet.json
Expand Down Expand Up @@ -69,7 +69,7 @@ fb03395b2b66dc861d110435b0d5c63a351123cd data/toughasnails/recipes/rain_collecto
2512026dc3a027f39db7e77e023a7017de386b9c data/toughasnails/recipes/sweet_berry_juice.json
e636bfd4fab8d516083454e872c8115f5c15cf27 data/toughasnails/recipes/temperature_gauge.json
b75d1caa0b1dcb9ae14dc02e47bba2a3c4b4a4dc data/toughasnails/recipes/thermometer.json
ec555eb461e41d183f1663ce4f9be35d3036d72d data/toughasnails/recipes/thermoregulator.json
354e18f4a33f2c769bc2063667cd1369a354f119 data/toughasnails/recipes/thermoregulator.json
cbfb7c82bd9547a1a134e3814136fbdbcdd5dc79 data/toughasnails/recipes/water_purifier.json
30229579a58927cae7011781b0936f7ca87888a4 data/toughasnails/recipes/wool_boots.json
25ff54ef0230fd94b0f881f7866b571f4729d254 data/toughasnails/recipes/wool_chestplate.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"G": {
"item": "minecraft:glass"
},
"I": {
"item": "minecraft:iron_ingot"
},
Expand All @@ -16,9 +13,9 @@
}
},
"pattern": [
"SGS",
"SIS",
"ITI",
"SGS"
"SIS"
],
"result": {
"item": "toughasnails:thermoregulator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"minecraft:magma_cream",
"minecraft:blaze_powder",
"minecraft:blaze_rod",
"minecraft:fire_charge",
"minecraft:coal",
"minecraft:charcoal",
"minecraft:coal_block",
Expand Down
26 changes: 24 additions & 2 deletions common/src/main/java/toughasnails/block/ThermoregulatorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@
******************************************************************************/
package toughasnails.block;

import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;

import java.util.function.ToIntFunction;

public class ThermoregulatorBlock extends Block
{
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
public static final BooleanProperty COOLING = BooleanProperty.create("cooling");
public static final BooleanProperty HEATING = BooleanProperty.create("heating");

public ThermoregulatorBlock(Properties properties)
{
super(properties);
this.registerDefaultState(this.stateDefinition.any().setValue(COOLING, false).setValue(HEATING, false));
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(COOLING, false).setValue(HEATING, false));
}

public static ToIntFunction<BlockState> lightLevel(int level)
Expand All @@ -32,9 +39,24 @@ public static ToIntFunction<BlockState> lightLevel(int level)
};
}

@Override
public BlockState getStateForPlacement(BlockPlaceContext $$0) {
return (BlockState)this.defaultBlockState().setValue(FACING, $$0.getHorizontalDirection().getOpposite());
}

@Override
public BlockState rotate(BlockState $$0, Rotation $$1) {
return (BlockState)$$0.setValue(FACING, $$1.rotate((Direction)$$0.getValue(FACING)));
}

@Override
public BlockState mirror(BlockState $$0, Mirror $$1) {
return $$0.rotate($$1.getRotation((Direction)$$0.getValue(FACING)));
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder)
{
builder.add(COOLING, HEATING);
builder.add(FACING, COOLING, HEATING);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,64 @@
{
"variants": {
"cooling=false,heating=false": {
"facing=east,cooling=false,heating=false": {
"model": "toughasnails:block/thermoregulator_inactive",
"y": 90
},
"facing=east,cooling=true,heating=false": {
"model": "toughasnails:block/thermoregulator_cooling_active",
"y": 90
},
"facing=east,cooling=false,heating=true": {
"model": "toughasnails:block/thermoregulator_heating_active",
"y": 90
},
"facing=east,cooling=true,heating=true": {
"model": "toughasnails:block/thermoregulator_active",
"y": 90
},
"facing=north,cooling=false,heating=false": {
"model": "toughasnails:block/thermoregulator_inactive"
},
"cooling=true,heating=false": {
"facing=north,cooling=true,heating=false": {
"model": "toughasnails:block/thermoregulator_cooling_active"
},
"cooling=false,heating=true": {
"facing=north,cooling=false,heating=true": {
"model": "toughasnails:block/thermoregulator_heating_active"
},
"cooling=true,heating=true": {
"facing=north,cooling=true,heating=true": {
"model": "toughasnails:block/thermoregulator_active"
},
"facing=south,cooling=false,heating=false": {
"model": "toughasnails:block/thermoregulator_inactive",
"y": 180
},
"facing=south,cooling=true,heating=false": {
"model": "toughasnails:block/thermoregulator_cooling_active",
"y": 180
},
"facing=south,cooling=false,heating=true": {
"model": "toughasnails:block/thermoregulator_heating_active",
"y": 180
},
"facing=south,cooling=true,heating=true": {
"model": "toughasnails:block/thermoregulator_active",
"y": 180
},
"facing=west,cooling=false,heating=false": {
"model": "toughasnails:block/thermoregulator_inactive",
"y": 270
},
"facing=west,cooling=true,heating=false": {
"model": "toughasnails:block/thermoregulator_cooling_active",
"y": 270
},
"facing=west,cooling=false,heating=true": {
"model": "toughasnails:block/thermoregulator_heating_active",
"y": 270
},
"facing=west,cooling=true,heating=true": {
"model": "toughasnails:block/thermoregulator_active",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
},
"elements": [
{
"from": [0, 16, 0],
"to": [8, 16, 16],
"from": [8, 16, 0],
"to": [16, 16, 16],
"faces": {
"up": {"uv": [0, 0, 8, 16], "texture": "#top"}
"up": {"uv": [0, 0, 8, 16], "rotation": 180, "texture": "#top"}
}
},
{
"from": [8, 16, 0],
"to": [16, 16, 16],
"from": [0, 16, 0],
"to": [8, 16, 16],
"faces": {
"up": {"uv": [8, 0, 16, 16], "texture": "#top"}
"up": {"uv": [8, 0, 16, 16], "rotation": 180, "texture": "#top"}
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
},
"elements": [
{
"from": [0, 16, 0],
"to": [8, 16, 16],
"from": [8, 16, 0],
"to": [16, 16, 16],
"faces": {
"up": {"uv": [0, 0, 8, 16], "texture": "#top"}
"up": {"uv": [0, 0, 8, 16], "rotation": 180, "texture": "#top"}
}
},
{
"from": [8, 16, 0],
"to": [16, 16, 16],
"from": [0, 16, 0],
"to": [8, 16, 16],
"faces": {
"up": {"uv": [8, 0, 16, 16], "texture": "#top_active"}
"up": {"uv": [8, 0, 16, 16], "rotation": 180, "texture": "#top_active"}
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
},
"elements": [
{
"from": [0, 16, 0],
"to": [8, 16, 16],
"from": [8, 16, 0],
"to": [16, 16, 16],
"faces": {
"up": {"uv": [0, 0, 8, 16], "texture": "#top_active"}
"up": {"uv": [0, 0, 8, 16], "rotation": 180, "texture": "#top_active"}
}
},
{
"from": [8, 16, 0],
"to": [16, 16, 16],
"from": [0, 16, 0],
"to": [8, 16, 16],
"faces": {
"up": {"uv": [8, 0, 16, 16], "texture": "#top"}
"up": {"uv": [8, 0, 16, 16], "rotation": 180, "texture": "#top"}
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
},
"elements": [
{
"from": [0, 16, 0],
"to": [8, 16, 16],
"from": [8, 16, 0],
"to": [16, 16, 16],
"faces": {
"up": {"uv": [0, 0, 8, 16], "texture": "#top"}
"up": {"uv": [0, 0, 8, 16], "rotation": 180, "texture": "#top"}
}
},
{
"from": [8, 16, 0],
"to": [16, 16, 16],
"from": [0, 16, 0],
"to": [8, 16, 16],
"faces": {
"up": {"uv": [8, 0, 16, 16], "texture": "#top"}
"up": {"uv": [8, 0, 16, 16], "rotation": 180, "texture": "#top"}
}
},
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"animation": {
"frametime": 15,
"frametime": 30,
"interpolate": true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void addTags(HolderLookup.Provider provider)

// Thermoregulator fuel
this.tag(ModTags.Items.THERMOREGULATOR_COOLING_FUEL).add(Items.ICE, Items.PACKED_ICE, Items.BLUE_ICE, Items.SNOWBALL, Items.SNOW, Items.SNOW_BLOCK, Items.POWDER_SNOW_BUCKET);
this.tag(ModTags.Items.THERMOREGULATOR_HEATING_FUEL).add(Items.MAGMA_BLOCK, Items.MAGMA_CREAM, Items.BLAZE_POWDER, Items.BLAZE_ROD, Items.COAL, Items.CHARCOAL, Items.COAL_BLOCK, Items.LAVA_BUCKET);
this.tag(ModTags.Items.THERMOREGULATOR_HEATING_FUEL).add(Items.MAGMA_BLOCK, Items.MAGMA_CREAM, Items.BLAZE_POWDER, Items.BLAZE_ROD, Items.FIRE_CHARGE, Items.COAL, Items.CHARCOAL, Items.COAL_BLOCK, Items.LAVA_BUCKET);

// Drinks
this.tag(ModTags.Items.DRINKS).addTags(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected void buildRecipes(RecipeOutput output)
ShapedRecipeBuilder.shaped(RecipeCategory.FOOD, TANItems.CHARC_0S).define('#', Items.CHARCOAL).define('S', Items.SUGAR).define('B', Items.BOWL).pattern(" # ").pattern("#S#").pattern(" B ").unlockedBy("has_charcoal", has(Items.CHARCOAL)).save(output);

// Blocks
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, TANBlocks.THERMOREGULATOR).define('S', Items.SMOOTH_STONE).define('I', Items.IRON_INGOT).define('G', Items.GLASS).define('T', TANItems.THERMOMETER).pattern("SGS").pattern("ITI").pattern("SGS").unlockedBy("has_thermometer", has(TANItems.THERMOMETER)).save(output);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, TANBlocks.THERMOREGULATOR).define('S', Items.SMOOTH_STONE).define('I', Items.IRON_INGOT).define('T', TANItems.THERMOMETER).pattern("SIS").pattern("ITI").pattern("SIS").unlockedBy("has_thermometer", has(TANItems.THERMOMETER)).save(output);
ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, TANBlocks.TEMPERATURE_GAUGE).define('G', Items.GLASS).define('Q', Items.QUARTZ).define('T', TANItems.THERMOMETER).define('B', Items.BRICK_SLAB).pattern("GGG").pattern("QTQ").pattern("BBB").unlockedBy("has_thermometer", has(TANItems.THERMOMETER)).save(output);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, TANBlocks.RAIN_COLLECTOR).define('W', ItemTags.PLANKS).define('S', Items.STRING).pattern("WSW").pattern("W W").pattern("WWW").unlockedBy("has_string", has(Items.STRING)).save(output);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, TANBlocks.WATER_PURIFIER).define('I', Items.COPPER_INGOT).define('C', Items.CHARCOAL).define('G', Items.GLASS).pattern("III").pattern("GCG").pattern("III").unlockedBy("has_copper_ingot", has(Items.COPPER_INGOT)).save(output);
Expand Down

0 comments on commit 8bccb2c

Please sign in to comment.