Skip to content

Commit

Permalink
correct materialcolors & material properties for copper blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Jul 19, 2023
1 parent 6e3d1fe commit f70f415
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.WeatheringCopper;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.NotNull;

Expand All @@ -20,18 +23,23 @@
@ParametersAreNonnullByDefault
public class AbstractCopperDoorBlock extends DoorBlock {

public static final Material SOFT_METAL = new Material.Builder(MaterialColor.METAL).build();
private final boolean canBeUsedByPlayers;

public static boolean canBeUsedByPlayers(WeatheringCopper.WeatherState state) {
public static Material materialFor(WeatheringCopper.WeatherState state) {
return switch (state) {
case UNAFFECTED, EXPOSED -> true;
default -> false;
case UNAFFECTED, EXPOSED -> SOFT_METAL;
default -> Material.METAL;
};
}

public AbstractCopperDoorBlock(Properties properties, boolean canBeUsedByPlayers) {
public static Properties propertiesFor(WeatheringCopper.WeatherState state) {
return Properties.of(materialFor(state), CWeatheringCopper.colorFor(state)).requiresCorrectToolForDrops().strength(5.0F).sound(SoundType.COPPER).noOcclusion();
}

public AbstractCopperDoorBlock(Properties properties) {
super(properties);
this.canBeUsedByPlayers = canBeUsedByPlayers;
this.canBeUsedByPlayers = material != Material.METAL;
}

private int getCloseSound() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;

public class AbstractCopperTrapdoorBlock extends TrapDoorBlock {
private final boolean canBeUsedByPlayers;

public AbstractCopperTrapdoorBlock(Properties properties, boolean canBeUsedByPlayers) {
public AbstractCopperTrapdoorBlock(Properties properties) {
super(properties);
this.canBeUsedByPlayers = canBeUsedByPlayers;
this.canBeUsedByPlayers = material != Material.METAL;
}

private int getCloseSound() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.WeatheringCopper;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MaterialColor;

import java.util.Optional;
import java.util.function.Predicate;
Expand Down Expand Up @@ -47,4 +48,13 @@ default void insert(Block block, boolean before, NonNullList<ItemStack> items, P
}
items.add(stack);
}

static MaterialColor colorFor(WeatheringCopper.WeatherState state) {
return switch (state) {
case UNAFFECTED -> MaterialColor.COLOR_ORANGE;
case EXPOSED -> MaterialColor.TERRACOTTA_LIGHT_GRAY;
case WEATHERED -> MaterialColor.WARPED_STEM;
case OXIDIZED -> MaterialColor.WARPED_NYLIUM;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public class CopperDoorBlock extends AbstractCopperDoorBlock implements CWeather

private final WeatherState weatherState;

public CopperDoorBlock(WeatherState weatherState, Properties properties, boolean canBeUsedByPlayers) {
super(properties, canBeUsedByPlayers);
public CopperDoorBlock(WeatherState weatherState, Properties properties) {
super(properties);
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ public class CopperTrapDoorBlock extends AbstractCopperTrapdoorBlock implements

private final WeatherState weatherState;

public CopperTrapDoorBlock(WeatherState weatherState, Properties properties, boolean canBeUsedByPlayers) {
super(properties, canBeUsedByPlayers);
public CopperTrapDoorBlock(WeatherState weatherState, Properties properties) {
super(properties);
this.weatherState = weatherState;
}

Expand Down
12 changes: 0 additions & 12 deletions src/main/java/galena/copperative/content/block/WaxedDoorBlock.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WeatheredCogBlock extends CogBlock implements CWeatheringCopper {
private final WeatherState weatherState;

public WeatheredCogBlock(WeatherState weatherState) {
super(Properties.copy(Blocks.COPPER_BLOCK).strength(3.0F, 6.0F).sound(SoundType.COPPER).requiresCorrectToolForDrops());
super(Properties.copy(Blocks.COPPER_BLOCK).strength(3.0F, 6.0F).sound(SoundType.COPPER).requiresCorrectToolForDrops().color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WeatheredCrank extends CrankBlock implements CWeatheringCopper {
private final WeatherState weatherState;

public WeatheredCrank(WeatherState weatherState) {
super(Properties.of(Material.WOOD, MaterialColor.NONE).strength(0.6F, 0.6F).noCollission().noOcclusion());
super(Properties.of(Material.METAL, MaterialColor.NONE).strength(0.6F, 0.6F).noCollission().noOcclusion());
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class WeatheredExposer extends ExposerBlock implements CWeatheringCopper
private final WeatherState weatherState;

public WeatheredExposer(WeatherState weatherState) {
super(Properties.copy(Blocks.OBSERVER).randomTicks());
super(Properties.copy(Blocks.OBSERVER).randomTicks().color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Block loadUnaffected() {
private final WeatherState weatherState;

public WeatheredRandomizer(WeatherState weatherState) {
super(Properties.of(Material.DECORATION).strength(0.0F).sound(SoundType.WOOD));
super(Properties.of(Material.DECORATION).strength(0.0F).sound(SoundType.COPPER));
this.registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH).setValue(POWERED, RandomizerPowerState.OFF));
this.weatherState = weatherState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WeatheredRelayer extends RelayerBlock implements CWeatheringCopper
private final WeatherState weatherState;

public WeatheredRelayer(WeatherState weatherState) {
super(BlockBehaviour.Properties.copy(Blocks.OBSERVER).randomTicks());
super(BlockBehaviour.Properties.copy(Blocks.OBSERVER).randomTicks().color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@

import galena.copperative.content.block.CWeatheringCopper;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;

import javax.annotation.ParametersAreNonnullByDefault;

@MethodsReturnNonnullByDefault
public class WeatheringDispenserBlock extends DispenserBlock implements CWeatheringCopper {

private final WeatherState weatherState;

public WeatheringDispenserBlock(WeatherState weatherState) {
super(Properties.copy(Blocks.DISPENSER).sound(SoundType.COPPER));
super(Properties.copy(Blocks.DISPENSER).sound(SoundType.COPPER).color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DropperBlock;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.WeatheringCopper;
import org.jetbrains.annotations.NotNull;

@MethodsReturnNonnullByDefault
Expand All @@ -18,7 +17,7 @@ public class WeatheringDropperBlock extends DropperBlock implements CWeatheringC
private final WeatherState weatherState;

public WeatheringDropperBlock(WeatherState weatherState) {
super(Properties.copy(Blocks.DROPPER).sound(SoundType.COPPER));
super(Properties.copy(Blocks.DROPPER).sound(SoundType.COPPER).color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class WeatheringObserverBlock extends ObserverBlock implements CWeatherin
private final WeatheringCopper.WeatherState weatherState;

public WeatheringObserverBlock(WeatherState weatherState) {
super(Properties.copy(Blocks.OBSERVER).sound(SoundType.COPPER));
super(Properties.copy(Blocks.OBSERVER).sound(SoundType.COPPER).color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class WeatheringPistonBlock extends PistonBaseBlock implements CWeatherin
private final boolean isSticky;

public WeatheringPistonBlock(WeatherState weatherState, boolean isSticky) {
super(isSticky, Properties.copy(isSticky ? Blocks.STICKY_PISTON : Blocks.PISTON).sound(SoundType.COPPER));
super(isSticky, Properties.copy(isSticky ? Blocks.STICKY_PISTON : Blocks.PISTON).sound(SoundType.COPPER).color(CWeatheringCopper.colorFor(weatherState)));
this.weatherState = weatherState;
this.isSticky = isSticky;
}
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/galena/copperative/index/CBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import java.util.function.UnaryOperator;
import java.util.stream.Stream;

import static galena.copperative.content.block.AbstractCopperDoorBlock.propertiesFor;
import static galena.copperative.content.block.CWeatheringCopper.colorFor;

public class CBlocks {

public static final CreativeModeTab REDSTONE = CreativeModeTab.TAB_REDSTONE;
Expand All @@ -46,13 +49,13 @@ public class CBlocks {
public static final RegistryObject<Block> PATINA_BLOCK = register("patina_block", () -> new SandBlock(0xBD3A0, Properties.copy(Blocks.SAND).sound(SoundType.TUFF)), BUILDING);

// Decorative Blocks
public static final List<RegistryObject<WeatheringCopperFullBlock>> COPPER_BRICKS = registerWeatheringSet("copper_bricks", weatherState -> new WeatheringCopperFullBlock(weatherState, Properties.copy(Blocks.CUT_COPPER)), BUILDING);
public static final List<RegistryObject<WeatheringPillarBlock>> COPPER_PILLAR = registerWeatheringSet("copper_pillar", weatherState -> new WeatheringPillarBlock(weatherState, Properties.copy(Blocks.CUT_COPPER)), BUILDING);
public static final List<RegistryObject<WeatheringPillarBlock>> COPPER_TILES = registerWeatheringSet("copper_tiles", weatherState -> new WeatheringPillarBlock(weatherState, Properties.copy(Blocks.CUT_COPPER)), BUILDING);
public static final List<RegistryObject<WeatheringCopperFullBlock>> COPPER_BRICKS = registerWeatheringSet("copper_bricks", weatherState -> new WeatheringCopperFullBlock(weatherState, Properties.copy(Blocks.CUT_COPPER).color(colorFor(weatherState))), BUILDING);
public static final List<RegistryObject<WeatheringPillarBlock>> COPPER_PILLAR = registerWeatheringSet("copper_pillar", weatherState -> new WeatheringPillarBlock(weatherState, Properties.copy(Blocks.CUT_COPPER).color(colorFor(weatherState))), BUILDING);
public static final List<RegistryObject<WeatheringPillarBlock>> COPPER_TILES = registerWeatheringSet("copper_tiles", weatherState -> new WeatheringPillarBlock(weatherState, Properties.copy(Blocks.CUT_COPPER).color(colorFor(weatherState))), BUILDING);

public static final List<RegistryObject<Block>> WAXED_COPPER_BRICKS = registerWaxedSet("copper_bricks", $ -> new Block(Properties.copy(Blocks.CUT_COPPER)), BUILDING);
public static final List<RegistryObject<RotatedPillarBlock>> WAXED_COPPER_PILLAR = registerWaxedSet("copper_pillar", $ -> new RotatedPillarBlock(Properties.copy(Blocks.CUT_COPPER)), BUILDING);
public static final List<RegistryObject<RotatedPillarBlock>> WAXED_COPPER_TILES = registerWaxedSet("copper_tiles", $ -> new RotatedPillarBlock(Properties.copy(Blocks.CUT_COPPER)), BUILDING);
public static final List<RegistryObject<Block>> WAXED_COPPER_BRICKS = registerWaxedSet("copper_bricks", state -> new Block(Properties.copy(Blocks.CUT_COPPER).color(colorFor(state))), BUILDING);
public static final List<RegistryObject<RotatedPillarBlock>> WAXED_COPPER_PILLAR = registerWaxedSet("copper_pillar", state -> new RotatedPillarBlock(Properties.copy(Blocks.CUT_COPPER).color(colorFor(state))), BUILDING);
public static final List<RegistryObject<RotatedPillarBlock>> WAXED_COPPER_TILES = registerWaxedSet("copper_tiles", state -> new RotatedPillarBlock(Properties.copy(Blocks.CUT_COPPER).color(colorFor(state))), BUILDING);

// Redstone Components
public static final RegistryObject<Block> EXPOSED_REPEATER = register("exposed_repeater", () -> new WeatheringRepeaterBlock(WeatherState.EXPOSED), REDSTONE);
Expand Down Expand Up @@ -86,22 +89,22 @@ public class CBlocks {
public static final RegistryObject<Block> WEATHERED_LEVER = register("weathered_lever", () -> new WeatheringLeverBlock(WeatherState.WEATHERED), REDSTONE);
public static final RegistryObject<Block> OXIDIZED_LEVER = register("oxidized_lever", () -> new WeatheringLeverBlock(WeatherState.OXIDIZED), REDSTONE);

public static final List<RegistryObject<DoorBlock>> COPPER_DOORS = registerWeatheringSet("copper_door", it -> new CopperDoorBlock(it, Properties.copy(Blocks.IRON_DOOR).sound(SoundType.COPPER), AbstractCopperDoorBlock.canBeUsedByPlayers(it)), REDSTONE);
public static final List<RegistryObject<DoorBlock>> COPPER_DOORS = registerWeatheringSet("copper_door", it -> new CopperDoorBlock(it, propertiesFor(it)), REDSTONE);

public static final List<RegistryObject<TrapDoorBlock>> COPPER_TRAPDOORS = registerWeatheringSet("copper_trapdoor", it -> new CopperTrapDoorBlock(it, Properties.copy(Blocks.IRON_TRAPDOOR).sound(SoundType.COPPER), AbstractCopperDoorBlock.canBeUsedByPlayers(it)), REDSTONE);
public static final List<RegistryObject<TrapDoorBlock>> COPPER_TRAPDOORS = registerWeatheringSet("copper_trapdoor", it -> new CopperTrapDoorBlock(it, propertiesFor(it)), REDSTONE);

public static final List<RegistryObject<DoorBlock>> WAXED_COPPER_DOORS = registerWaxedSet("copper_door", it -> new WaxedDoorBlock(Properties.copy(Blocks.IRON_DOOR).sound(SoundType.COPPER), AbstractCopperDoorBlock.canBeUsedByPlayers(it)), REDSTONE);
public static final List<RegistryObject<DoorBlock>> WAXED_COPPER_DOORS = registerWaxedSet("copper_door", it -> new AbstractCopperDoorBlock(propertiesFor(it)), REDSTONE);

public static final List<RegistryObject<TrapDoorBlock>> WAXED_COPPER_TRAPDOORS = registerWaxedSet("copper_trapdoor", it -> new AbstractCopperTrapdoorBlock(Properties.copy(Blocks.IRON_TRAPDOOR).sound(SoundType.COPPER), AbstractCopperDoorBlock.canBeUsedByPlayers(it)), REDSTONE);
public static final List<RegistryObject<TrapDoorBlock>> WAXED_COPPER_TRAPDOORS = registerWaxedSet("copper_trapdoor", it -> new AbstractCopperTrapdoorBlock(propertiesFor(it)), REDSTONE);


public static final List<RegistryObject<Block>> HEADLIGHT = registerWeatheringSet("headlight", weatherState -> new HeadLightBlock(weatherState, Properties.copy(Blocks.COPPER_BLOCK).lightLevel(HeadLightBlock.LIGHT_EMISSION)), REDSTONE);
public static final List<RegistryObject<Block>> HEADLIGHT = registerWeatheringSet("headlight", weatherState -> new HeadLightBlock(weatherState, Properties.copy(Blocks.COPPER_BLOCK).lightLevel(HeadLightBlock.LIGHT_EMISSION).color(CWeatheringCopper.colorFor(weatherState))), REDSTONE);
public static final RegistryObject<BlockEntityType<HeadlightTile>> HEADLIGHT_TILE = BLOCK_ENTITIES.register("headlight", () -> {
var blocks = HEADLIGHT.stream().map(RegistryObject::get).toArray(Block[]::new);
return BlockEntityType.Builder.of(HeadlightTile::new, blocks).build(null);
});

public static final List<RegistryObject<Block>> TOGGLER = registerWeatheringSet("toggler", weatherState -> new TogglerBlock(weatherState, Properties.copy(Blocks.COPPER_BLOCK)), REDSTONE);
public static final List<RegistryObject<Block>> TOGGLER = registerWeatheringSet("toggler", weatherState -> new TogglerBlock(weatherState, Properties.copy(Blocks.REPEATER).sound(SoundType.COPPER)), REDSTONE);

// Rails
public static final RegistryObject<Block> EXPOSED_POWERED_RAIL = register("exposed_powered_rail", () -> new WeatheringPoweredRailBlock(WeatherState.EXPOSED), TRANSPORT);
Expand Down

0 comments on commit f70f415

Please sign in to comment.