Skip to content

Commit

Permalink
Further updates to match vanilla 1.21.2 changes.
Browse files Browse the repository at this point in the history
- Bump version to 12.0.0-alpha.2
- Reordered args of TerraformDesertSaplingBlock constructor to place block settings last
- Added block settings factories for custom log blocks to PillarLogHelper
- Deprecated now-useless instance factories of BareSmallLogBlock, SmallLogBlock, and QuarterLogBlock
  • Loading branch information
gniftygnome committed Nov 10, 2024
1 parent 74c77f1 commit d442782
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

maven_group=com.terraformersmc.terraform-api
version=12.0.0-alpha.1
version=12.0.0-alpha.2

minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class TerraformDesertSaplingBlock extends SaplingBlock {
private final boolean onlySand;

public TerraformDesertSaplingBlock(SaplingGenerator generator, Settings settings) {
this(generator, settings, false);
this(generator, false, settings);
}

public TerraformDesertSaplingBlock(SaplingGenerator generator, Settings settings, boolean onlySand) {
public TerraformDesertSaplingBlock(SaplingGenerator generator, boolean onlySand, Settings settings) {
super(generator, settings);
this.onlySand = onlySand;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ public BareSmallLogBlock(AbstractBlock.Settings settings) {
* Factory to create a BareSmallLogBlock with default settings and
* the same map color on all block faces.
*
* @deprecated Use {@linkplain PillarLogHelper#createSettings(MapColor)}
* @param color Map color for all faces of log
* @return New BareSmallLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static BareSmallLogBlock of(MapColor color) {
return new BareSmallLogBlock(AbstractBlock.Settings.create()
.mapColor(color)
Expand All @@ -91,10 +93,12 @@ public static BareSmallLogBlock of(MapColor color) {
* Factory to create a BareSmallLogBlock with default settings and
* different map colors on the top/bottom versus the sides.
*
* @deprecated Use {@linkplain PillarLogHelper#createSettings(MapColor, MapColor)}
* @param wood Map color for non-bark faces of log (ends)
* @param bark Map color for bark faces of log (sides)
* @return New BareSmallLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static BareSmallLogBlock of(MapColor wood, MapColor bark) {
return new BareSmallLogBlock(AbstractBlock.Settings.create()
.mapColor((state) -> state.get(UP) ? wood : bark)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.terraformersmc.terraform.wood.api.block;

import net.minecraft.block.*;
import net.minecraft.block.enums.NoteBlockInstrument;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.block.PillarBlock;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.Direction;

Expand All @@ -12,24 +14,23 @@ private PillarLogHelper() {
}

/**
* Factory to create default block settings for a PillarBlock log with
* the same map color on all block faces.
* Factory to create default block settings for a PillarBlock, QuarterLogBlock,
* or BareSmallLogBlock log with the same map color on all block faces.
*
* @param color Map color for all faces of log
* @return New AbstractBlock.Settings
*/
public static AbstractBlock.Settings createSettings(MapColor color) {
return AbstractBlock.Settings.create()
.mapColor(color)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable();
}

/**
* Factory to create default block settings for a PillarBlock log with
* different map colors on the top/bottom versus the sides.
* Factory to create default block settings for a PillarBlock or BareSmallLogBlock
* log with different map colors on the top/bottom versus the sides.
*
* @param wood Map color for non-bark faces of log (ends)
* @param bark Map color for bark faces of log (sides)
Expand All @@ -38,7 +39,76 @@ public static AbstractBlock.Settings createSettings(MapColor color) {
public static AbstractBlock.Settings createSettings(MapColor wood, MapColor bark) {
return AbstractBlock.Settings.create()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable();
}

/**
* Factory to create default block settings for a QuarterLogBlock
* log with different map colors on the bark versus the cut faces.
*
* @param wood Map color for cut faces of log
* @param bark Map color for bark faces of log
* @return New AbstractBlock.Settings
*/
public static AbstractBlock.Settings createQuarterLogSettings(MapColor wood, MapColor bark) {
return AbstractBlock.Settings.create()
.mapColor(
(state) ->
switch (state.get(PillarBlock.AXIS)) {
case Y -> wood;
case X ->
switch (state.get(QuarterLogBlock.BARK_SIDE)) {
case NORTHWEST, SOUTHWEST -> bark;
case NORTHEAST, SOUTHEAST -> wood;
};
case Z ->
switch (state.get(QuarterLogBlock.BARK_SIDE)) {
case SOUTHEAST, SOUTHWEST -> bark;
case NORTHEAST, NORTHWEST -> wood;
};
}
)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable();
}

/**
* Factory to create default block settings for a SmallLogBlock
* log with the same map color on all block faces.
*
* If there is no associated LeavesBlock, instead use
* {@linkplain PillarLogHelper#createSettings(MapColor)}
*
* @param leaves Associated LeavesBlock
* @param color Map color for all faces of log
* @return New AbstractBlock.Settings
*/
public static AbstractBlock.Settings createSmallLogSettings(Block leaves, MapColor color) {
return AbstractBlock.Settings.create()
.mapColor((state) -> state.get(SmallLogBlock.HAS_LEAVES) ? leaves.getDefaultMapColor() : color)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable();
}

/**
* Factory to create default block settings for a SmallLogBlock
* log with different map colors on the top/bottom versus the sides.
*
* If there is no associated LeavesBlock, instead use
* {@linkplain PillarLogHelper#createSettings(MapColor, MapColor)}
*
* @param leaves Associated LeavesBlock
* @param wood Map color for non-bark faces of log (ends)
* @param bark Map color for bark faces of log (sides)
* @return New AbstractBlock.Settings
*/
public static AbstractBlock.Settings createSmallLogSettings(Block leaves, MapColor wood, MapColor bark) {
return AbstractBlock.Settings.create()
.mapColor((state) -> state.get(SmallLogBlock.HAS_LEAVES) ? leaves.getDefaultMapColor() : state.get(SmallLogBlock.UP) ? wood : bark)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable();
Expand All @@ -54,7 +124,6 @@ public static AbstractBlock.Settings createSettings(MapColor wood, MapColor bark
public static AbstractBlock.Settings createNetherSettings(MapColor color) {
return AbstractBlock.Settings.create()
.mapColor(color)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM);
}
Expand All @@ -70,7 +139,36 @@ public static AbstractBlock.Settings createNetherSettings(MapColor color) {
public static AbstractBlock.Settings createNetherSettings(MapColor wood, MapColor bark) {
return AbstractBlock.Settings.create()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.instrument(NoteBlockInstrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM);
}

/**
* Factory to create default block settings for a QuarterLogBlock Nether
* stem with different map colors on the bark versus the cut faces.
*
* @param wood Map color for cut faces of log
* @param bark Map color for bark faces of log
* @return New AbstractBlock.Settings
*/
public static AbstractBlock.Settings createQuarterLogNetherSettings(MapColor wood, MapColor bark) {
return AbstractBlock.Settings.create()
.mapColor(
(state) ->
switch (state.get(PillarBlock.AXIS)) {
case Y -> wood;
case X ->
switch (state.get(QuarterLogBlock.BARK_SIDE)) {
case NORTHWEST, SOUTHWEST -> bark;
case NORTHEAST, SOUTHEAST -> wood;
};
case Z ->
switch (state.get(QuarterLogBlock.BARK_SIDE)) {
case SOUTHEAST, SOUTHWEST -> bark;
case NORTHEAST, NORTHWEST -> wood;
};
}
)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.util.math.Vec3d;

/**
* A log block that has 4 different corners that combine together to form a huge and continuous 2x2 log.
* A log block that has 4 different corners that combine to form a huge and continuous 2x2 log.
* Used for the mega variants of Redwood, Fir, etc
*/
@SuppressWarnings("unused")
Expand All @@ -30,9 +30,11 @@ public QuarterLogBlock(AbstractBlock.Settings settings) {
* Factory to create a QuarterLogBlock with default settings and
* the same map color on all block faces.
*
* @deprecated Use {@linkplain PillarLogHelper#createSettings(MapColor)}
* @param color Map color for all faces of log
* @return New QuarterLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static QuarterLogBlock of(MapColor color) {
return new QuarterLogBlock(AbstractBlock.Settings.create()
.mapColor(color)
Expand All @@ -46,10 +48,12 @@ public static QuarterLogBlock of(MapColor color) {
* Factory to create a QuarterLogBlock with default settings and
* different map colors on the exposed wood versus the bark sides.
*
* @deprecated Use {@linkplain PillarLogHelper#createQuarterLogSettings(MapColor, MapColor)}
* @param wood Map color for non-bark faces of log
* @param bark Map color for bark faces of log
* @return New QuarterLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static QuarterLogBlock of(MapColor wood, MapColor bark) {
return new QuarterLogBlock(AbstractBlock.Settings.create()
.mapColor(
Expand Down Expand Up @@ -78,9 +82,11 @@ public static QuarterLogBlock of(MapColor wood, MapColor bark) {
* Factory to create a Nether QuarterLogBlock with default settings and
* the same map color on all block faces.
*
* @deprecated Use {@linkplain PillarLogHelper#createNetherSettings(MapColor)}
* @param color Map color for all faces of log
* @return New QuarterLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static QuarterLogBlock ofNether(MapColor color) {
return new QuarterLogBlock(AbstractBlock.Settings.create()
.mapColor(color)
Expand All @@ -93,10 +99,12 @@ public static QuarterLogBlock ofNether(MapColor color) {
* Factory to create a Nether QuarterLogBlock with default settings and
* different map colors on the exposed wood versus the bark sides.
*
* @deprecated Use {@linkplain PillarLogHelper#createQuarterLogNetherSettings(MapColor, MapColor)}
* @param wood Map color for non-bark faces of log
* @param bark Map color for bark faces of log
* @return New QuarterLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static QuarterLogBlock ofNether(MapColor wood, MapColor bark) {
return new QuarterLogBlock(AbstractBlock.Settings.create()
.mapColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public SmallLogBlock(Block leaves, Settings settings) {
* Factory to create a SmallLogBlock with default settings and
* the same map color on all block faces.
*
* @deprecated Use {@linkplain PillarLogHelper#createSmallLogSettings(Block, MapColor)}
* @param leaves Block used for leaves on log
* @param color Map color for all faces of log
* @return New SmallLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static SmallLogBlock of(Block leaves, MapColor color) {
return new SmallLogBlock(leaves, AbstractBlock.Settings.create()
.mapColor((state) -> state.get(HAS_LEAVES) ? leaves.getDefaultMapColor() : color)
Expand All @@ -73,11 +75,13 @@ public static SmallLogBlock of(Block leaves, MapColor color) {
* Factory to create a SmallLogBlock with default settings and
* different map colors on the top/bottom versus the sides.
*
* @deprecated Use {@linkplain PillarLogHelper#createSmallLogSettings(Block, MapColor, MapColor)}
* @param leaves Block used for leaves on log
* @param wood Map color for non-bark faces of log (ends)
* @param bark Map color for bark faces of log (sides)
* @return New SmallLogBlock
*/
@Deprecated(since = "12.0.0", forRemoval = true)
public static SmallLogBlock of(Block leaves, MapColor wood, MapColor bark) {
return new SmallLogBlock(leaves, AbstractBlock.Settings.create()
.mapColor((state) -> state.get(HAS_LEAVES) ? leaves.getDefaultMapColor() : state.get(UP) ? wood : bark)
Expand Down

0 comments on commit d442782

Please sign in to comment.