mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-24 08:38:17 -05:00
Restart Testmods (#593)
This commit is contained in:
parent
7b6f8bc5f3
commit
045efb4682
24 changed files with 76 additions and 1066 deletions
18
build.gradle
18
build.gradle
|
@ -57,6 +57,13 @@ allprojects {
|
|||
|
||||
group = "net.fabricmc.fabric-api"
|
||||
|
||||
sourceSets {
|
||||
testmod {
|
||||
compileClasspath += main.compileClasspath
|
||||
runtimeClasspath += main.runtimeClasspath
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:$Globals.mcVersion"
|
||||
mappings "net.fabricmc:yarn:${Globals.mcVersion}${Globals.yarnVersion}:v2"
|
||||
|
@ -149,6 +156,11 @@ task javadocJar(type: Jar) {
|
|||
build.dependsOn javadocJar
|
||||
|
||||
subprojects {
|
||||
|
||||
dependencies {
|
||||
testmodCompile sourceSets.main.output
|
||||
}
|
||||
|
||||
task remapMavenJar(type: Copy, dependsOn: remapJar) {
|
||||
afterEvaluate {
|
||||
from("${project.buildDir}/libs/$archivesBaseName-${version}.jar")
|
||||
|
@ -228,11 +240,17 @@ task licenseFormatAll
|
|||
subprojects { p -> licenseFormatAll.dependsOn("${p.path}:licenseFormat") }
|
||||
subprojects.each { remapJar.dependsOn("${it.path}:remapJar") }
|
||||
|
||||
sourceSets {
|
||||
testmod
|
||||
}
|
||||
|
||||
dependencies {
|
||||
afterEvaluate {
|
||||
subprojects.each {
|
||||
compile project(path: ":${it.name}", configuration: "dev")
|
||||
include project("${it.name}:")
|
||||
|
||||
testmodCompile project("${it.name}:").sourceSets.testmod.output
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
- largely unconstained trailing subpackages
|
||||
-->
|
||||
<property name="format"
|
||||
value="^net\.fabricmc\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+\.v[1-9][0-9]*|(impl|mixin)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+|api\.(event|util|biomes\.v1|registry|client\.screen|container|block|entity|client\.itemgroup|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$"/>
|
||||
value="^net\.fabricmc\.fabric\.(api(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+\.v[1-9][0-9]*|(impl|mixin|test)(?!\.common\.)(\.client|\.server|)(\.(?!client\.|server\.)[a-z]+[a-rt-z])+|api\.(event|util|biomes\.v1|registry|client\.screen|container|block|entity|client\.itemgroup|client\.keybinding|tag|tools|client\.model|network|server|client\.render|resource|client\.texture))(|\.[a-z]+(\.[a-z0-9]+)*)$"/>
|
||||
</module>
|
||||
|
||||
<!--<module name="InvalidJavadocPosition"/>-->
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.test.item.group;
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
|
||||
public class ItemGroupTest implements ModInitializer {
|
||||
//Adds an item group with all items in it
|
||||
private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("fabric-item-groups-v0-testmod", "test_group"))
|
||||
.icon(() -> new ItemStack(Items.DIAMOND))
|
||||
.appendItems(stacks ->
|
||||
Registry.ITEM.stream()
|
||||
.map(ItemStack::new)
|
||||
.forEach(stacks::add)
|
||||
).build();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
}
|
||||
}
|
16
fabric-item-groups-v0/src/testmod/resources/fabric.mod.json
Normal file
16
fabric-item-groups-v0/src/testmod/resources/fabric.mod.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fabric-item-groups-v0-testmod",
|
||||
"name": "Fabric Item Groups (v0) Test Mod",
|
||||
"version": "1.0.0",
|
||||
"environment": "*",
|
||||
"license": "Apache-2.0",
|
||||
"depends": {
|
||||
"fabric-item-groups-v0": "*"
|
||||
},
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"net.fabricmc.fabric.test.item.group.ItemGroupTest"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.block;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
||||
public class FireMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
FlammableBlockRegistry.getDefaultInstance().add(Blocks.STONE, 100, 100);
|
||||
FlammableBlockRegistry.getDefaultInstance().remove(Blocks.OAK_PLANKS);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.colormapper;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.render.ColorProviderRegistry;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.render.block.BlockColorMapper;
|
||||
import net.minecraft.item.Items;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ColorProviderMod implements ClientModInitializer {
|
||||
private static final boolean ENABLED = true;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
if (!ENABLED) return;
|
||||
LOGGER.info("Initialising ColorProviderMod");
|
||||
|
||||
// Redstone is now the same color as grass
|
||||
ColorProviderRegistry.BLOCK.register((block, world, pos, layer) -> {
|
||||
BlockColorMapper provider = ColorProviderRegistry.BLOCK.get(Blocks.GRASS);
|
||||
return provider == null ? -1 : provider.getColor(block, world, pos, layer);
|
||||
}, Blocks.REDSTONE_WIRE);
|
||||
|
||||
// Make white dye glow red.
|
||||
ColorProviderRegistry.ITEM.register((item, layer) ->
|
||||
(int) (64 * (Math.sin(System.currentTimeMillis() / 5e2) + 3)) << 16,
|
||||
Items.WHITE_DYE);
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.commands;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
|
||||
public class CommandMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
CommandRegistry.INSTANCE.register(false, (dispatcher) -> dispatcher.register(
|
||||
CommandManager.literal("fabric_test")
|
||||
.executes(c -> {
|
||||
c.getSource().sendFeedback(new StringTextComponent("Command works!"), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
));
|
||||
|
||||
CommandRegistry.INSTANCE.register(true, (dispatcher) -> dispatcher.register(
|
||||
CommandManager.literal("fabric_test_dedicated")
|
||||
.executes(c -> {
|
||||
c.getSource().sendFeedback(new StringTextComponent("Command works!"), false);
|
||||
return Command.SINGLE_SUCCESS;
|
||||
})
|
||||
));
|
||||
}
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.containers;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
||||
import net.fabricmc.fabric.api.registry.CommandRegistry;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.container.Slot;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class ContainerMod implements ModInitializer {
|
||||
|
||||
public static final Identifier EXAMPLE_CONTAINER = new Identifier("fabric_container", "example_container");
|
||||
public static final Identifier EXAMPLE_CONTAINER_2 = new Identifier("fabric_container", "example_container_2");
|
||||
public static final Identifier EXAMPLE_INVENTORY_CONTAINER = new Identifier("fabric_container", "example_inventory_container");
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
//Registers a basic server side command that shows that the openContainer works from the server side.
|
||||
CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher ->
|
||||
serverCommandSourceCommandDispatcher.register(CommandManager
|
||||
.literal("container")
|
||||
.executes(context -> {
|
||||
BlockPos pos = new BlockPos(context.getSource().getEntity());
|
||||
|
||||
//Opens a container, sending the block pos
|
||||
ContainerProviderRegistry.INSTANCE.openContainer(EXAMPLE_INVENTORY_CONTAINER, context.getSource().getPlayer(), buf -> buf.writeBlockPos(pos));
|
||||
|
||||
return 1;
|
||||
})));
|
||||
|
||||
//Registers a container factory that opens our example Container, this reads the block pos from the buffer
|
||||
ContainerProviderRegistry.INSTANCE.registerFactory(EXAMPLE_CONTAINER, (syncId, identifier, player, buf) -> {
|
||||
BlockPos pos = buf.readBlockPos();
|
||||
return new ExampleContainer(syncId, pos, player);
|
||||
});
|
||||
ContainerProviderRegistry.INSTANCE.registerFactory(EXAMPLE_CONTAINER_2, (syncId, identifier, player, buf) -> {
|
||||
BlockPos pos = buf.readBlockPos();
|
||||
return new ExampleContainer(syncId, pos, player);
|
||||
});
|
||||
ContainerProviderRegistry.INSTANCE.registerFactory(EXAMPLE_INVENTORY_CONTAINER, (syncId, identifier, player, buf) -> {
|
||||
return new ExampleInventoryContainer(syncId, player);
|
||||
});
|
||||
}
|
||||
|
||||
//A basic container that prints to console when opened, this should print on the client + server
|
||||
public static class ExampleContainer extends Container {
|
||||
public final PlayerInventory playerInventory;
|
||||
BlockPos pos;
|
||||
|
||||
public ExampleContainer(int syncId, BlockPos pos, PlayerEntity playerEntity) {
|
||||
super(null, syncId);
|
||||
this.pos = pos;
|
||||
this.playerInventory = playerEntity.inventory;
|
||||
System.out.println("Opened container, " + pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(PlayerEntity playerEntity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExampleInventoryContainer extends Container {
|
||||
public final PlayerInventory playerInventory;
|
||||
BlockPos pos;
|
||||
|
||||
public ExampleInventoryContainer(int syncId, PlayerEntity playerEntity) {
|
||||
super(null, syncId);
|
||||
this.playerInventory = playerEntity.inventory;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse(PlayerEntity playerEntity) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.containers;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
|
||||
import net.minecraft.client.gui.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.StringTextComponent;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class ContainerModClient implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
//Registers a gui factory that opens our example gui, this reads the block pos from the buffer
|
||||
ScreenProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER, (syncId, identifier, player, buf) -> {
|
||||
BlockPos pos = buf.readBlockPos();
|
||||
return new ExampleContainerScreen(syncId, pos, player);
|
||||
});
|
||||
|
||||
//Registers a gui factory that opens our example gui, this uses the container created by ContainerProviderRegistry
|
||||
ScreenProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER_2, ExampleContainerScreen2::new);
|
||||
|
||||
//Registers a gui factory that opens our example inventory gui
|
||||
ScreenProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_INVENTORY_CONTAINER, ExampleInventoryContainerScreen::new);
|
||||
}
|
||||
|
||||
//A container gui that shows the block pos that was sent
|
||||
public static class ExampleContainerScreen extends ContainerScreen<ContainerMod.ExampleContainer> {
|
||||
|
||||
BlockPos pos;
|
||||
|
||||
public ExampleContainerScreen(int syncId, BlockPos pos, PlayerEntity playerEntity) {
|
||||
super(new ContainerMod.ExampleContainer(syncId, pos, playerEntity), playerEntity.inventory, new StringTextComponent("Example GUI"));
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float v, int i, int i1) {
|
||||
font.draw(pos.toString(), width / 2, height / 2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//A container gui that shows how you can take in a container provided by a ContainerScreenFactory
|
||||
public static class ExampleContainerScreen2 extends ContainerScreen<ContainerMod.ExampleContainer> {
|
||||
|
||||
BlockPos pos;
|
||||
|
||||
public ExampleContainerScreen2(ContainerMod.ExampleContainer container) {
|
||||
super(container, container.playerInventory, new StringTextComponent("Example GUI 2"));
|
||||
this.pos = container.pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float v, int i, int i1) {
|
||||
font.draw(pos.toString(), width / 2, height / 2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//A container gui that has the player's inventory
|
||||
public static class ExampleInventoryContainerScreen extends ContainerScreen<ContainerMod.ExampleInventoryContainer> {
|
||||
|
||||
private static final Identifier BG_TEXTURE = new Identifier("textures/gui/container/horse.png");
|
||||
|
||||
public ExampleInventoryContainerScreen(ContainerMod.ExampleInventoryContainer container) {
|
||||
super(container, container.playerInventory, new StringTextComponent("Example Inventory GUI"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float v, int i, int i1) {
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
minecraft.getTextureManager().bindTexture(BG_TEXTURE);
|
||||
this.blit(left, top, 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.events;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockApplyCallback;
|
||||
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockGatherCallback;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
|
||||
public class PickBlockEventModClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ClientPickBlockGatherCallback.EVENT.register((player, result) -> {
|
||||
if (result instanceof BlockHitResult) {
|
||||
BlockView view = player.getEntityWorld();
|
||||
BlockPos pos = ((BlockHitResult) result).getBlockPos();
|
||||
BlockState state = view.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() == Blocks.STONE) {
|
||||
return new ItemStack(Blocks.OAK_WOOD);
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.EMPTY;
|
||||
});
|
||||
|
||||
ClientPickBlockApplyCallback.EVENT.register((player, result, stack) -> {
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.OAK_WOOD)) {
|
||||
return new ItemStack(Blocks.ACACIA_WOOD);
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.events;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.server.ServerStartCallback;
|
||||
import net.fabricmc.fabric.api.event.server.ServerStopCallback;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ServerEventMod implements ModInitializer {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ServerStartCallback.EVENT.register(server -> LOGGER.info("Server starting (" + server + ")"));
|
||||
ServerStopCallback.EVENT.register(server -> LOGGER.info("Server stopping (" + server + ")"));
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.fluidrender;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.render.FluidRenderHandler;
|
||||
import net.fabricmc.fabric.api.client.render.FluidRenderHandlerRegistry;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class FluidRendererModClient implements ClientModInitializer, SimpleSynchronousResourceReloadListener {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getFabricId() {
|
||||
return new Identifier("fabric:fluid_renderer_test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(ResourceManager rm) {
|
||||
FluidRenderHandler lavaHandler = FluidRenderHandlerRegistry.INSTANCE.get(Fluids.LAVA);
|
||||
FluidRenderHandlerRegistry.INSTANCE.register(Fluids.WATER, lavaHandler);
|
||||
FluidRenderHandlerRegistry.INSTANCE.register(Fluids.FLOWING_WATER, lavaHandler);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.item;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Items;
|
||||
|
||||
public class FuelMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
FuelRegistry.INSTANCE.add(Items.APPLE, 200);
|
||||
FuelRegistry.INSTANCE.remove(Blocks.OAK_PLANKS);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.itemgroup;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
|
||||
public class ItemGroupMod implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
//This creates your standard Item Group
|
||||
ItemGroup group = FabricItemGroupBuilder.build(new Identifier("fabric", "fabric_test_tab"), () -> new ItemStack(Items.IRON_CHESTPLATE));
|
||||
Item testItem = new Item(new Item.Settings().itemGroup(group));
|
||||
Registry.ITEM.add(new Identifier("fabric_test", "itemgroup"), testItem);
|
||||
|
||||
//Creates a tab with all items (including ones that dont show in search such as the command block)
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "all")).appendItems(itemStacks -> Registry.ITEM.forEach(item -> itemStacks.add(new ItemStack(item)))).build();
|
||||
|
||||
//Creates a group with all modded items in
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "modded")).appendItems(itemStacks -> Registry.ITEM.forEach(item -> {
|
||||
if (!Registry.ITEM.getId(item).getNamespace().equals("minecraft")) {
|
||||
itemStacks.add(new ItemStack(item));
|
||||
}
|
||||
})).icon(() -> new ItemStack(Blocks.TNT)).build();
|
||||
|
||||
|
||||
//These are just padding to ensure more than one page works
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test1")).icon(() -> new ItemStack(Items.APPLE)).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test2")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test3")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test4")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test5")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test6")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test7")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test8")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test9")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test10")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test11")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test12")).build();
|
||||
FabricItemGroupBuilder.create(new Identifier("fabric", "test13")).build();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.keybinding;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
|
||||
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class KeyBindingModClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
KeyBindingRegistry.INSTANCE.addCategory("fabric.test");
|
||||
KeyBindingRegistry.INSTANCE.register(
|
||||
FabricKeyBinding.Builder.create(
|
||||
new Identifier("fabric:test"),
|
||||
InputUtil.Type.KEYSYM,
|
||||
37,
|
||||
"fabric.test"
|
||||
).build()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.loot;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.registry.LootEntryTypeRegistry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.world.loot.condition.LootCondition;
|
||||
import net.minecraft.world.loot.entry.LootEntry;
|
||||
import net.minecraft.world.loot.entry.TagEntry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LootEntryMod implements ModInitializer {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LootEntryTypeRegistry.INSTANCE.register(new TestSerializer());
|
||||
}
|
||||
|
||||
private static class TestSerializer extends LootEntry.Serializer<TagEntry> {
|
||||
private static final TagEntry.Serializer SERIALIZER = new TagEntry.Serializer();
|
||||
|
||||
public TestSerializer() {
|
||||
super(new Identifier("fabric", "extended_tag"), TagEntry.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJson(JsonObject obj, TagEntry entry, JsonSerializationContext context) {
|
||||
SERIALIZER.method_451(obj, entry, context);
|
||||
obj.addProperty("fabric", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagEntry fromJson(JsonObject var1, JsonDeserializationContext var2, LootCondition[] var3) {
|
||||
LOGGER.info("Is this a Fabric loot entry? " + JsonHelper.getBoolean(var1, "fabric", true));
|
||||
return SERIALIZER.fromJson(var1, var2, var3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.loot;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.loot.LootTableLoadingCallback;
|
||||
import net.fabricmc.fabric.api.loot.FabricLootPoolBuilder;
|
||||
import net.fabricmc.fabric.api.loot.LootUtilities;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.world.loot.ConstantLootTableRange;
|
||||
import net.minecraft.world.loot.LootPool;
|
||||
import net.minecraft.world.loot.condition.SurvivesExplosionLootCondition;
|
||||
import net.minecraft.world.loot.entry.ItemEntry;
|
||||
import net.minecraft.world.loot.entry.LootEntry;
|
||||
|
||||
public class LootTableMod implements ModInitializer {
|
||||
private static final String LOOT_ENTRY_JSON = "{\"type\":\"minecraft:item\",\"name\":\"minecraft:apple\"}";
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
LootTableLoadingCallback.EVENT.register((manager, id, supplier) -> {
|
||||
if ("minecraft:blocks/dirt".equals(id.toString())) {
|
||||
LootEntry entryFromString = LootUtilities.readEntryFromJson(LOOT_ENTRY_JSON);
|
||||
|
||||
LootPool pool = FabricLootPoolBuilder.builder()
|
||||
.withEntry(ItemEntry.builder(Items.FEATHER))
|
||||
.withEntry(entryFromString)
|
||||
.withRolls(ConstantLootTableRange.create(1))
|
||||
.withCondition(SurvivesExplosionLootCondition.method_871())
|
||||
.build();
|
||||
|
||||
supplier.withPool(pool);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.model;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
|
||||
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.model.json.ModelItemPropertyOverrideList;
|
||||
import net.minecraft.client.render.model.json.ModelTransformation;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.util.ModelIdentifier;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class ModelModClient implements ClientModInitializer {
|
||||
private static BakedModel bakedModel;
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ModelLoadingRegistry.INSTANCE.registerAppender((manager, out) -> {
|
||||
System.out.println("--- ModelAppender called! ---");
|
||||
out.accept(new ModelIdentifier("fabric:model#custom"));
|
||||
});
|
||||
|
||||
ModelLoadingRegistry.INSTANCE.registerVariantProvider(manager -> ((modelId, context) -> {
|
||||
if (modelId.getVariant().equals("custom") && modelId.getNamespace().equals("fabric")) {
|
||||
System.out.println("--- ModelVariantProvider called! ---");
|
||||
return context.loadModel(new Identifier("fabric:custom"));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
ModelLoadingRegistry.INSTANCE.registerResourceProvider(manager -> ((id, context) -> {
|
||||
if (id.toString().equals("fabric:custom")) {
|
||||
return context.loadModel(new Identifier("fabric:custom2"));
|
||||
} else if (id.toString().equals("fabric:custom2")) {
|
||||
System.out.println("--- ModelResourceProvider called! ---");
|
||||
return new UnbakedModel() {
|
||||
@Override
|
||||
public Collection<Identifier> getModelDependencies() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Identifier> getTextureDependencies(Function<Identifier, UnbakedModel> var1, Set<String> var2) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BakedModel bake(ModelLoader var1, Function<Identifier, Sprite> var2, ModelBakeSettings var3) {
|
||||
System.out.println("--- Model baked! ---");
|
||||
|
||||
return bakedModel = new BakedModel() {
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(BlockState var1, Direction var2, Random var3) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAmbientOcclusion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDepthInGui() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprite getSprite() {
|
||||
return MinecraftClient.getInstance().getSpriteAtlas().getSprite("missingno");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelTransformation getTransformation() {
|
||||
return ModelTransformation.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelItemPropertyOverrideList getItemPropertyOverrides() {
|
||||
return ModelItemPropertyOverrideList.EMPTY;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
ClientTickCallback.EVENT.register((client) -> {
|
||||
if (client.getBakedModelManager().getModel(new ModelIdentifier("fabric:model#custom"))
|
||||
== bakedModel && bakedModel != null) {
|
||||
System.out.println("--- MODEL LOADED! ---");
|
||||
} else {
|
||||
System.out.println("--- MODEL NOT LOADED! ---");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.particle;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.FabricSpriteProvider;
|
||||
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
||||
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.particle.AnimatedParticle;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleFactory;
|
||||
import net.minecraft.client.particle.ParticleTextureSheet;
|
||||
import net.minecraft.client.particle.SpriteBillboardParticle;
|
||||
import net.minecraft.client.particle.SpriteProvider;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ParticleModClient implements ClientModInitializer, ModInitializer {
|
||||
public static final DefaultParticleType SIMPLE_TEST_PARTICLE = FabricParticleTypes.simple();
|
||||
public static final DefaultParticleType CUSTOM_TEST_PARTICLE = FabricParticleTypes.simple();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Registry.register(Registry.PARTICLE_TYPE, new Identifier("testmod", "simple"), SIMPLE_TEST_PARTICLE);
|
||||
Registry.register(Registry.PARTICLE_TYPE, new Identifier("testmod", "custom"), CUSTOM_TEST_PARTICLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
ParticleFactoryRegistry.getInstance().register(SIMPLE_TEST_PARTICLE, SimpleTestParticle::new);
|
||||
ParticleFactoryRegistry.getInstance().register(CUSTOM_TEST_PARTICLE, CustomTestParticle.Factory::new);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
static class SimpleTestParticle extends SpriteBillboardParticle {
|
||||
public SimpleTestParticle(ParticleEffect effect, World world, double x, double y, double z, double velX, double velY, double velZ) {
|
||||
super(world, x, y, z, velX, velY, velZ);
|
||||
setSprite(MinecraftClient.getInstance().getItemRenderer().getModels().getSprite(Blocks.BARRIER.asItem()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParticleTextureSheet getType() {
|
||||
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
|
||||
}
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
static class CustomTestParticle extends AnimatedParticle {
|
||||
protected CustomTestParticle(World world, double x, double y, double z, SpriteProvider sprites) {
|
||||
super(world, x, y, z, sprites, 1);
|
||||
setSprite(sprites.getSprite(world.random));
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class Factory implements ParticleFactory<DefaultParticleType> {
|
||||
private final FabricSpriteProvider sprites;
|
||||
|
||||
public Factory(FabricSpriteProvider sprites) {
|
||||
this.sprites = sprites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Particle createParticle(DefaultParticleType type, World world, double x, double y, double z, double vX, double vY, double vZ) {
|
||||
return new CustomTestParticle(world, x, y, z, sprites);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.resources;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ResourceReloadModClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
for (int i = 64; i >= 2; i--) {
|
||||
final int _i = i;
|
||||
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
|
||||
@Override
|
||||
public void apply(ResourceManager var1) {
|
||||
System.out.println("Reloading (should run as #" + _i + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getFabricId() {
|
||||
return new Identifier("fabric:rrmc" + _i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Identifier> getFabricDependencies() {
|
||||
return Collections.singletonList(new Identifier("fabric:rrmc" + (_i - 1)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
|
||||
@Override
|
||||
public Identifier getFabricId() {
|
||||
return new Identifier("fabric:rrmc1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(ResourceManager var1) {
|
||||
System.out.println("Reloading (should run as #1)");
|
||||
}
|
||||
});
|
||||
|
||||
ResourceManagerHelper.get(ResourceType.ASSETS).registerReloadListener(new SimpleSynchronousResourceReloadListener() {
|
||||
@Override
|
||||
public Identifier getFabricId() {
|
||||
return new Identifier("fabric:rrmc_should_not_resolve");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Identifier> getFabricDependencies() {
|
||||
return Collections.singletonList(new Identifier("fabric:rrmc_nonexistent"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(ResourceManager var1) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"textures": [
|
||||
"minecraft:spell_7",
|
||||
"minecraft:spell_6",
|
||||
"minecraft:spell_5",
|
||||
"minecraft:spell_4",
|
||||
"minecraft:spell_3",
|
||||
"minecraft:spell_2",
|
||||
"minecraft:spell_1",
|
||||
"minecraft:spell_0"
|
||||
]
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,44 +0,0 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:alternatives",
|
||||
"children": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:match_tool",
|
||||
"predicate": {
|
||||
"enchantments": [
|
||||
{
|
||||
"enchantment": "minecraft:silk_touch",
|
||||
"levels": {
|
||||
"min": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"name": "minecraft:stone"
|
||||
},
|
||||
{
|
||||
"type": "fabric:extended_tag",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
],
|
||||
"name": "minecraft:wool",
|
||||
"expand": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"id": "fabric_test",
|
||||
"name": "Fabric API Tests",
|
||||
"version": "0.1.1",
|
||||
"side": "universal",
|
||||
"description": "A series of test mods to check Fabric works.",
|
||||
"license": "Apache-2.0",
|
||||
"initializers": [
|
||||
"net.fabricmc.fabric.colormapper.ColorProviderMod",
|
||||
"net.fabricmc.fabric.events.ServerEventMod",
|
||||
"net.fabricmc.fabric.containers.ContainerMod",
|
||||
"net.fabricmc.fabric.containers.ContainerModClient",
|
||||
"net.fabricmc.fabric.loot.LootEntryMod"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue