net.minecraft.util.DyeColor Java Examples

The following examples show how to use net.minecraft.util.DyeColor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HopperBlockEntityMixin.java    From fabric-carpet with MIT License 6 votes vote down vote up
@Inject(method = "insert", at = @At("HEAD"), cancellable = true)
private void onInsert(CallbackInfoReturnable<Boolean> cir)
{
    if (CarpetSettings.hopperCounters) {
        DyeColor wool_color = WoolTool.getWoolColorAtPosition(
                getWorld(),
                new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING)));
        if (wool_color != null)
        {
            for (int i = 0; i < this.getInvSize(); ++i)
            {
                if (!this.getInvStack(i).isEmpty())
                {
                    ItemStack itemstack = this.getInvStack(i);//.copy();
                    HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack);
                    this.setInvStack(i, ItemStack.EMPTY);
                }
            }
            cir.setReturnValue(true);
        }
    }
}
 
Example #2
Source File: LoggerRegistry.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static void registerLoggers()
{
    registerLogger("tnt", Logger.stardardLogger( "tnt", "brief", new String[]{"brief", "full"}));
    registerLogger("projectiles", Logger.stardardLogger("projectiles", "brief",  new String[]{"brief", "full"}));
    registerLogger("fallingBlocks",Logger.stardardLogger("fallingBlocks", "brief", new String[]{"brief", "full"}));
    //registerLogger("kills", new Logger("kills", null, null));
    //registerLogger("damage", new Logger("damage", "all", new String[]{"all","players","me"}));
    //registerLogger("weather", new Logger("weather", null, null));
    registerLogger( "pathfinding", Logger.stardardLogger("pathfinding", "20", new String[]{"2", "5", "10"}));

    registerLogger("tps", HUDLogger.stardardHUDLogger("tps", null, null));
    registerLogger("packets", HUDLogger.stardardHUDLogger("packets", null, null));
    registerLogger("counter",HUDLogger.stardardHUDLogger("counter","white", Arrays.stream(DyeColor.values()).map(Object::toString).toArray(String[]::new)));
    registerLogger("mobcaps", HUDLogger.stardardHUDLogger("mobcaps", "dynamic",new String[]{"dynamic", "overworld", "nether","end"}));
    registerLogger("explosions", HUDLogger.stardardLogger("explosions", "brief",new String[]{"brief", "full"}));

}
 
Example #3
Source File: IForgeBlock.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Re-colors this block in the world.
 *
 * @param state   The current state
 * @param world   The world
 * @param pos     Block position
 * @param facing  ??? (this method has no usages)
 * @param color   Color to recolor to.
 * @return if the block was affected
 */
@SuppressWarnings("unchecked")
default boolean recolorBlock(BlockState state, IWorld world, BlockPos pos, Direction facing, DyeColor color) {
	for (Property<?> prop : state.getProperties()) {
		if (prop.getName().equals("color") && prop.getType() == DyeColor.class) {
			DyeColor current = (DyeColor) state.get(prop);

			if (current != color && prop.getValues().contains(color)) {
				world.setBlockState(pos, state.with(((Property<DyeColor>) prop), color), 3);
				return true;
			}
		}
	}

	return false;
}
 
Example #4
Source File: CounterCommand.java    From fabric-carpet with MIT License 6 votes vote down vote up
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
    LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = CommandManager.literal("counter").executes((context)
     -> listAllCounters(context.getSource(), false)).requires((player) ->
            CarpetSettings.hopperCounters);

    literalargumentbuilder.
            then((CommandManager.literal("reset").executes( (p_198489_1_)->
                    resetCounter(p_198489_1_.getSource(), null))));
    for (DyeColor enumDyeColor: DyeColor.values())
    {
        String color = enumDyeColor.toString();
        literalargumentbuilder.
                then((CommandManager.literal(color).executes( (p_198489_1_)-> displayCounter(p_198489_1_.getSource(), color, false))));
        literalargumentbuilder.then(CommandManager.literal(color).
                then(CommandManager.literal("reset").executes((context) ->
                        resetCounter(context.getSource(), color))));
        literalargumentbuilder.then(CommandManager.literal(color).
                then(CommandManager.literal("realtime").executes((context) ->
                        displayCounter(context.getSource(), color, true))));
    }
    dispatcher.register(literalargumentbuilder);
}
 
Example #5
Source File: SpawnReporter.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static EntityCategory get_type_code_from_wool_code(DyeColor color)
{
    switch (color)
    {
        case RED:
            return EntityCategory.MONSTER;
        case GREEN:
            return EntityCategory.CREATURE;
        case BLUE:
            return EntityCategory.WATER_CREATURE;
        case BROWN:
            return EntityCategory.AMBIENT;
    }
    return null;
}
 
Example #6
Source File: MixinBannerBlockEntity.java    From multiconnect with MIT License 5 votes vote down vote up
@Unique
private void setBaseColor(DyeColor color) {
    BlockState state = getCachedState();
    if (!getType().supports(state.getBlock()))
        return;

    BlockState newState;
    if (state.getBlock() instanceof WallBannerBlock) {
        newState = WALL_BANNERS_BY_COLOR.get(color).getDefaultState().with(WallBannerBlock.FACING, state.get(WallBannerBlock.FACING));
    } else {
        newState = BannerBlock.getForColor(color).getDefaultState().with(BannerBlock.ROTATION, state.get(BannerBlock.ROTATION));
    }
    assert world != null;
    world.setBlockState(getPos(), newState, 18);
}
 
Example #7
Source File: SpawnReporter.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static List<BaseText> show_mobcaps(BlockPos pos, World worldIn)
{
    DyeColor under = WoolTool.getWoolColorAtPosition(worldIn, pos.down());
    if (under == null)
    {
        if (track_spawns > 0L)
        {
            return tracking_report(worldIn);
        }
        else
        {
            return printMobcapsForDimension(worldIn.dimension.getType(), true );
        }
    }
    EntityCategory creature_type = get_type_code_from_wool_code(under);
    if (creature_type != null)
    {
        if (track_spawns > 0L)
        {
            return recent_spawns(worldIn, creature_type);
        }
        else
        {
            return printEntitiesByType(creature_type, worldIn, true);
            
        }
        
    }
    if (track_spawns > 0L)
    {
        return tracking_report(worldIn);
    }
    else
    {
        return printMobcapsForDimension(worldIn.dimension.getType(), true );
    }
    
}
 
Example #8
Source File: WoolTool.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static DyeColor getWoolColorAtPosition(World worldIn, BlockPos pos)
{
    BlockState state = worldIn.getBlockState(pos);
    if (state.getMaterial() != Material.WOOL || !state.isSimpleFullBlock(worldIn, pos))
        return null;
    return Material2Dye.get(state.getTopMaterialColor(worldIn, pos));
}
 
Example #9
Source File: HopperCounter.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static HopperCounter getCounter(String color)
{
    try
    {
        DyeColor colorEnum = DyeColor.valueOf(color.toUpperCase(Locale.ROOT));
        return COUNTERS.get(colorEnum);
    }
    catch (IllegalArgumentException e)
    {
        return null;
    }
}
 
Example #10
Source File: HopperCounter.java    From fabric-carpet with MIT License 4 votes vote down vote up
private HopperCounter(DyeColor color)
{
    this.color = color;
    // pubSubProvider = new PubSubInfoProvider<>(QuickCarpet.PUBSUB, "carpet.counter." + color.getName(), 0, this::getTotalItems);
}
 
Example #11
Source File: SpawnCommand.java    From fabric-carpet with MIT License 4 votes vote down vote up
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
    LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("spawn").
            requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandSpawn));

    literalargumentbuilder.
            then(literal("list").
                    then(argument("pos", BlockPosArgumentType.blockPos()).
                            executes( (c) -> listSpawns(c.getSource(), BlockPosArgumentType.getBlockPos(c, "pos"))))).
            then(literal("tracking").
                    executes( (c) -> printTrackingReport(c.getSource())).
                    then(literal("start").
                            executes( (c) -> startTracking(c.getSource(), null, null)).
                            then(argument("from", BlockPosArgumentType.blockPos()).
                                    then(argument("to", BlockPosArgumentType.blockPos()).
                                            executes( (c) -> startTracking(
                                                    c.getSource(),
                                                    BlockPosArgumentType.getBlockPos(c, "from"),
                                                    BlockPosArgumentType.getBlockPos(c, "to")))))).
                    then(literal("stop").
                            executes( (c) -> stopTracking(c.getSource()))).
                    then(argument("type", word()).
                            suggests( (c, b) -> suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName),b)).
                            executes( (c) -> recentSpawnsForType(c.getSource(), getString(c, "type"))))).
            then(literal("test").
                    executes( (c)-> runTest(c.getSource(), 72000, null)).
                    then(argument("ticks", integer(10,720000)).
                            executes( (c)-> runTest(
                                    c.getSource(),
                                    getInteger(c, "ticks"),
                                    null)).
                            then(argument("counter", word()).
                                    suggests( (c, b) -> suggestMatching(Arrays.stream(DyeColor.values()).map(DyeColor::toString),b)).
                                    executes((c)-> runTest(
                                            c.getSource(),
                                            getInteger(c, "ticks"),
                                            getString(c, "counter")))))).
            then(literal("mocking").
                    then(argument("to do or not to do?", BoolArgumentType.bool()).
                        executes( (c) -> toggleMocking(c.getSource(), BoolArgumentType.getBool(c, "to do or not to do?"))))).
            then(literal("rates").
                    executes( (c) -> generalMobcaps(c.getSource())).
                    then(literal("reset").
                            executes( (c) -> resetSpawnRates(c.getSource()))).
                    then(argument("type", word()).
                            suggests( (c, b) -> suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName),b)).
                            then(argument("rounds", integer(0)).
                                    suggests( (c, b) -> suggestMatching(new String[]{"1"},b)).
                                    executes( (c) -> setSpawnRates(
                                            c.getSource(),
                                            getString(c, "type"),
                                            getInteger(c, "rounds")))))).
            then(literal("mobcaps").
                    executes( (c) -> generalMobcaps(c.getSource())).
                    then(literal("set").
                            then(argument("cap (hostile)", integer(1,1400)).
                                    executes( (c) -> setMobcaps(c.getSource(), getInteger(c, "cap (hostile)"))))).
                    then(argument("dimension", DimensionArgumentType.dimension()).
                            executes( (c)-> mobcapsForDimension(c.getSource(), DimensionArgumentType.getDimensionArgument(c, "dimension"))))).
            then(literal("entities").
                    executes( (c) -> generalMobcaps(c.getSource()) ).
                    then(argument("type", string()).
                            suggests( (c, b)->suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName), b)).
                            executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"), false)).
                            then(literal("all").executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"), true)))));

    dispatcher.register(literalargumentbuilder);
}
 
Example #12
Source File: FluidPipeBlock.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public FluidPipeBlock(Settings settings) {
    super(settings);
    setDefaultState(this.getStateManager().getDefaultState().with(PULL, false).with(COLOR, DyeColor.WHITE).with(ATTACHED_NORTH, false).with(ATTACHED_EAST, false).with(ATTACHED_SOUTH, false).with(ATTACHED_WEST, false).with(ATTACHED_UP, false).with(ATTACHED_DOWN, false));
}
 
Example #13
Source File: MixinSheepEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Shadow
public abstract DyeColor getColor();
 
Example #14
Source File: MixinBannerBlockEntity.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "fromTag", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/entity/BlockEntity;fromTag(Lnet/minecraft/block/BlockState;Lnet/minecraft/nbt/CompoundTag;)V", shift = At.Shift.AFTER))
private void readBase(BlockState blockState, CompoundTag tag, CallbackInfo ci) {
    if (ConnectionInfo.protocolVersion <= Protocols.V1_12_2) {
        setBaseColor(DyeColor.byId(15 - tag.getInt("Base")));
    }
}
 
Example #15
Source File: HallowedCarpetBlock.java    From the-hallow with MIT License 4 votes vote down vote up
public HallowedCarpetBlock(DyeColor color, Settings settings) {
	super(color, settings);
}
 
Example #16
Source File: IForgeBlockState.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Re-colors this block in the world.
 *
 * @param state   The current state
 * @param world   The world
 * @param pos     Block position
 * @param facing  ??? (this method has no usages)
 * @param color   Color to recolor to.
 * @return if the block was affected
 */
default boolean recolorBlock(IWorld world, BlockPos pos, Direction facing, DyeColor color) {
	return patchwork$getForgeBlock().recolorBlock(getBlockState(), world, pos, facing, color);
}
 
Example #17
Source File: MixinBedBlockEntity.java    From multiconnect with MIT License votes vote down vote up
@Shadow public abstract void setColor(DyeColor color);