Skip to content

Commit

Permalink
Update for 23w17a
Browse files Browse the repository at this point in the history
- Updated for Minecraft 23w17a
- Added QuarterLogBlock.ofNether()
* Removal of Material and new Block.Settings
  • Loading branch information
gniftygnome committed Apr 28, 2023
1 parent 471aa69 commit 823c162
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 105 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ org.gradle.jvmargs=-Xmx2G
fabric.loom.multiProjectOptimisation=true

maven_group=com.terraformersmc.terraform-api
version=7.0.0-alpha.4
version=7.0.0-alpha.5

minecraft_version=23w16a
yarn_mappings=23w16a+build.4
minecraft_version=23w17a
yarn_mappings=23w17a+build.7
loader_version=0.14.19
fabric_version=0.78.1+1.20
fabric_version=0.79.1+1.20

mixin_extras_version=0.2.0-beta.5
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.WoodType;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
import net.minecraft.client.render.TexturedRenderLayers;
import net.minecraft.client.util.SpriteIdentifier;
Expand All @@ -22,7 +22,7 @@ public class MixinSignEditScreen {
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/TexturedRenderLayers;getSignTextureId(Lnet/minecraft/block/WoodType;)Lnet/minecraft/client/util/SpriteIdentifier;")
)
@SuppressWarnings("unused")
private SpriteIdentifier getTerraformSignTextureId(WoodType type, Operation<SpriteIdentifier> original, DrawableHelper drawContext, BlockState state) {
private SpriteIdentifier getTerraformSignTextureId(WoodType type, Operation<SpriteIdentifier> original, DrawContext drawContext, BlockState state) {
if (state.getBlock() instanceof TerraformSign signBlock) {
return new SpriteIdentifier(TexturedRenderLayers.SIGNS_ATLAS_TEXTURE, signBlock.getTexture());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public BareSmallLogBlock(Supplier<Block> stripped, Block.Settings settings) {
* @return New BareSmallLogBlock
*/
public static BareSmallLogBlock of(MapColor color) {
return new BareSmallLogBlock(
Block.Settings.of(
Material.GENERIC,
color
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new BareSmallLogBlock(Block.Settings.of()
.mapColor(color)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand All @@ -121,11 +121,11 @@ public static BareSmallLogBlock of(MapColor color) {
* @return New BareSmallLogBlock
*/
public static BareSmallLogBlock of(MapColor wood, MapColor bark) {
return new BareSmallLogBlock(
Block.Settings.of(
Material.GENERIC,
(state) -> state.get(UP) ? wood : bark
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new BareSmallLogBlock(Block.Settings.of()
.mapColor((state) -> state.get(UP) ? wood : bark)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand Down Expand Up @@ -296,29 +296,24 @@ public FluidState getFluidState(BlockState state) {

@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
switch (rotation) {
case CLOCKWISE_180:
return state.with(NORTH, state.get(SOUTH)).with(EAST, state.get(WEST)).with(SOUTH, state.get(NORTH)).with(WEST, state.get(EAST));
case COUNTERCLOCKWISE_90:
return state.with(NORTH, state.get(EAST)).with(EAST, state.get(SOUTH)).with(SOUTH, state.get(WEST)).with(WEST, state.get(NORTH));
case CLOCKWISE_90:
return state.with(NORTH, state.get(WEST)).with(EAST, state.get(NORTH)).with(SOUTH, state.get(EAST)).with(WEST, state.get(SOUTH));
default:
return state;
}

return switch (rotation) {
case CLOCKWISE_180 ->
state.with(NORTH, state.get(SOUTH)).with(EAST, state.get(WEST)).with(SOUTH, state.get(NORTH)).with(WEST, state.get(EAST));
case COUNTERCLOCKWISE_90 ->
state.with(NORTH, state.get(EAST)).with(EAST, state.get(SOUTH)).with(SOUTH, state.get(WEST)).with(WEST, state.get(NORTH));
case CLOCKWISE_90 ->
state.with(NORTH, state.get(WEST)).with(EAST, state.get(NORTH)).with(SOUTH, state.get(EAST)).with(WEST, state.get(SOUTH));
default -> state;
};
}

@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
switch (mirror) {
case LEFT_RIGHT:
return state.with(NORTH, state.get(SOUTH)).with(SOUTH, state.get(NORTH));
case FRONT_BACK:
return state.with(EAST, state.get(WEST)).with(WEST, state.get(EAST));
default:
return super.mirror(state, mirror);
}
return switch (mirror) {
case LEFT_RIGHT -> state.with(NORTH, state.get(SOUTH)).with(SOUTH, state.get(NORTH));
case FRONT_BACK -> state.with(EAST, state.get(WEST)).with(WEST, state.get(EAST));
default -> super.mirror(state, mirror);
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public class PillarLogHelper {
* @return New PillarBlock
*/
public static PillarBlock of(MapColor color) {
return new PillarBlock(
Block.Settings.of(
Material.GENERIC,
color
).method_51368(Instrument.BASS).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new PillarBlock(Block.Settings.of()
.mapColor(color)
.instrument(Instrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand All @@ -32,11 +33,12 @@ public static PillarBlock of(MapColor color) {
* @return New PillarBlock
*/
public static PillarBlock of(MapColor wood, MapColor bark) {
return new PillarBlock(
Block.Settings.of(
Material.GENERIC,
(state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark
).method_51368(Instrument.BASS).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new PillarBlock(Block.Settings.of()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.instrument(Instrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand All @@ -48,11 +50,11 @@ public static PillarBlock of(MapColor wood, MapColor bark) {
* @return New PillarBlock
*/
public static PillarBlock ofNether(MapColor color) {
return new PillarBlock(
Block.Settings.of(
Material.GENERIC,
color
).method_51368(Instrument.BASS).strength(2.0F).sounds(BlockSoundGroup.NETHER_STEM)
return new PillarBlock(Block.Settings.of()
.mapColor(color)
.instrument(Instrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM)
);
}

Expand All @@ -65,11 +67,11 @@ public static PillarBlock ofNether(MapColor color) {
* @return New PillarBlock
*/
public static PillarBlock ofNether(MapColor wood, MapColor bark) {
return new PillarBlock(
Block.Settings.of(
Material.GENERIC,
(state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark
).method_51368(Instrument.BASS).strength(2.0F).sounds(BlockSoundGroup.NETHER_STEM)
return new PillarBlock(Block.Settings.of()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.instrument(Instrument.BASS)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_STEM)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* A log block that has 4 different corners that combine together to form a huge and continuous 2x2 log.
* Used for the mega variants of Redwood, Fir, etc
*/
@SuppressWarnings("unused")
public class QuarterLogBlock extends PillarBlock {
public static final EnumProperty<BarkSide> BARK_SIDE = EnumProperty.of("bark_side", BarkSide.class);

Expand Down Expand Up @@ -59,11 +60,11 @@ public QuarterLogBlock(Supplier<Block> stripped, MapColor color, Block.Settings
* @return New QuarterLogBlock
*/
public static QuarterLogBlock of(MapColor color) {
return new QuarterLogBlock(
Block.Settings.of(
Material.GENERIC,
color
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new QuarterLogBlock(Block.Settings.of()
.mapColor(color)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand All @@ -76,24 +77,72 @@ public static QuarterLogBlock of(MapColor color) {
* @return New QuarterLogBlock
*/
public static QuarterLogBlock of(MapColor wood, MapColor bark) {
return new QuarterLogBlock(
Block.Settings.of(
Material.GENERIC,
return new QuarterLogBlock(Block.Settings.of()
.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()
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 a Nether QuarterLogBlock with default settings and
* the same map color on all block faces.
*
* @param color Map color for all faces of log
* @return New QuarterLogBlock
*/
public static QuarterLogBlock ofNether(MapColor color) {
return new QuarterLogBlock(Block.Settings.of()
.mapColor(color)
.strength(2.0F)
.sounds(BlockSoundGroup.NETHER_WOOD)
);
}

/**
* Factory to create a Nether QuarterLogBlock with default settings and
* different map colors on the exposed wood versus the bark sides.
*
* @param wood Map color for non-bark faces of log
* @param bark Map color for bark faces of log
* @return New QuarterLogBlock
*/
public static QuarterLogBlock ofNether(MapColor wood, MapColor bark) {
return new QuarterLogBlock(Block.Settings.of()
.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_WOOD)
);
}

Expand Down Expand Up @@ -150,18 +199,18 @@ public static BarkSide fromHit(Direction.Axis axis, float hitX, float hitY, floa
boolean hitSouth;

switch (axis) {
case Y:
case Y -> {
hitEast = hitX >= 0.5;
hitSouth = hitZ >= 0.5;
break;
case X:
}
case X -> {
hitEast = hitY <= 0.5;
hitSouth = hitZ >= 0.5;
break;
default:
}
default -> {
hitEast = hitX >= 0.5;
hitSouth = hitY >= 0.5;
break;
}
}

// Logic of placement: The quadrant the player clicks on should be the one farthest from the bark sides.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public SmallLogBlock(Block leaves, Supplier<Block> stripped, Settings settings)
* @return New SmallLogBlock
*/
public static SmallLogBlock of(Block leaves, MapColor color) {
return new SmallLogBlock(leaves,
Block.Settings.of(
Material.GENERIC,
(state) -> state.get(HAS_LEAVES) ? leaves.getDefaultMapColor() : color
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new SmallLogBlock(leaves, Block.Settings.of()
.mapColor((state) -> state.get(HAS_LEAVES) ? leaves.getDefaultMapColor() : color)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand All @@ -106,12 +106,11 @@ public static SmallLogBlock of(Block leaves, MapColor color) {
* @return New SmallLogBlock
*/
public static SmallLogBlock of(Block leaves, MapColor wood, MapColor bark) {
return new SmallLogBlock(leaves,
Block.Settings.of(
Material.GENERIC,
(state) -> state.get(HAS_LEAVES) ? leaves.getDefaultMapColor() :
state.get(UP) ? wood : bark
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new SmallLogBlock(leaves, Block.Settings.of()
.mapColor((state) -> state.get(HAS_LEAVES) ? leaves.getDefaultMapColor() : state.get(UP) ? wood : bark)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material;
import net.minecraft.block.PillarBlock;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -51,11 +50,11 @@ public StrippableLogBlock(Supplier<Block> stripped, MapColor top, Settings setti
* @return New PillarBlock
*/
public static PillarBlock of(MapColor color) {
return new PillarBlock(
Block.Settings.of(
Material.GENERIC,
color
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new PillarBlock(Block.Settings.of()
.mapColor(color)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}

Expand All @@ -67,11 +66,11 @@ public static PillarBlock of(MapColor color) {
* @return New PillarBlock
*/
public static PillarBlock of(MapColor wood, MapColor bark) {
return new PillarBlock(
Block.Settings.of(
Material.GENERIC,
(state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark
).strength(2.0F).sounds(BlockSoundGroup.WOOD).burnable()
return new PillarBlock(Block.Settings.of()
.mapColor((state) -> Direction.Axis.Y.equals(state.get(PillarBlock.AXIS)) ? wood : bark)
.strength(2.0F)
.sounds(BlockSoundGroup.WOOD)
.burnable()
);
}
}

0 comments on commit 823c162

Please sign in to comment.