Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Major Loader Rework #21

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
71c2941
Start sandbox rewrite
TheCodedOne Nov 7, 2020
1410a5b
Remove old code
TheCodedOne Nov 7, 2020
78c84bf
Fix fabric missing build.gradle
TheCodedOne Nov 8, 2020
e41a0dc
Add registry wrappers
TheCodedOne Nov 9, 2020
2890817
Add ItemStack injection mixins
TheCodedOne Nov 10, 2020
dae31e0
Re-implement roman numeral enchantment fix
TheCodedOne Nov 10, 2020
6378427
Add conditional block entities & Start basic loading system
TheCodedOne Nov 11, 2020
27791c7
Bring fabric fixes to forge
TheCodedOne Nov 13, 2020
e053bb7
Update branding
TheCodedOne Dec 15, 2020
9c9a6da
Update SandboxAPI
TheCodedOne Dec 15, 2020
36eb22d
Work on some mixins
TheCodedOne Dec 15, 2020
6f8309f
Dont talk to me about class loaders
TheCodedOne Dec 20, 2020
ae004f9
Cleanup code
TheCodedOne Dec 20, 2020
9cdcbe3
Fix block items wrapping as regular items
TheCodedOne Dec 20, 2020
4cfaf15
Merge remote-tracking branch 'origin/develop' into feature/sandbox2
TheCodedOne Jan 15, 2021
52c6700
Update architectury & gradle. Start targetting Java 11
TheCodedOne Jan 15, 2021
5a20d42
Make up to date with current rework branch of Sandbox API
TheCodedOne Jan 15, 2021
0b5bfef
Move to using gradle toolchains
TheCodedOne Jan 16, 2021
4eba9f2
Start merging mixins into common module where applicable
TheCodedOne Jan 16, 2021
80331c0
Bring loader up in sync with rework API
TheCodedOne Jan 25, 2021
9bda958
Update SandboxAPI
TheCodedOne Jan 30, 2021
6dfc858
Remove erroneous import
Bluexin Jan 30, 2021
afdfc75
Remove unused methods in internal service
TheCodedOne Jan 30, 2021
697b336
Implement better custom tool support
TheCodedOne Feb 23, 2021
8a4ea2e
Fix forge bootstrap not starting Sandbox
TheCodedOne Feb 23, 2021
6b6ac9f
Update gradle to 6.8.3
TheCodedOne Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,18 @@ run/*

!run/addons/test/*
logs/

*/build
/build
/bin
*/bin
/.gradle
*/.gradle
/minecraft
*/minecraft
/out
*/run
*/out
/run
/classes
logs/
2 changes: 1 addition & 1 deletion SandboxAPI
10 changes: 4 additions & 6 deletions TestAddon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ plugins {

repositories {
mavenCentral()
maven { url 'https://dl.bintray.com/sandboxpowered/API/' }
maven { url 'https://dl.bintray.com/sandboxpowered/Library/' }
}

dependencies {
implementation platform("org.sandboxpowered.api:api:0.4.+")
implementation platform("org.sandboxpowered.api:api:0.5.+")

implementation "org.sandboxpowered.api:base"
implementation "org.sandboxpowered.api:rendering"
implementation "org.sandboxpowered.api:resources"

compileOnly group: 'org.jetbrains', name: 'annotations', version: '19.0.0'
implementation 'com.electronwill.night-config:core:3.6.0'
implementation 'com.electronwill.night-config:toml:3.6.0'
implementation 'com.github.zafarkhaja:java-semver:0.9.0'
implementation 'org.sandboxpowered:SimpleEventHandler:2.0.3'
implementation group: 'com.google.guava', name: 'guava', version: '21.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
implementation 'com.electronwill.night-config:toml:3.6.3'
implementation 'com.electronwill.night-config:core:3.6.3'
compileOnly 'org.jetbrains:annotations:20.1.0'
}
124 changes: 99 additions & 25 deletions TestAddon/src/main/java/org/sandboxpowered/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,126 @@

import org.sandboxpowered.api.SandboxAPI;
import org.sandboxpowered.api.addon.Addon;
import org.sandboxpowered.api.block.Block;
import org.sandboxpowered.api.block.Blocks;
import org.sandboxpowered.api.block.Material;
import org.sandboxpowered.api.block.entity.BlockEntity;
import org.sandboxpowered.api.entity.player.Hand;
import org.sandboxpowered.api.entity.player.PlayerEntity;
import org.sandboxpowered.api.block.*;
import org.sandboxpowered.api.events.BlockEvents;
import org.sandboxpowered.api.item.BaseBlockItem;
import org.sandboxpowered.api.events.ItemEvents;
import org.sandboxpowered.api.item.BaseItem;
import org.sandboxpowered.api.item.Item;
import org.sandboxpowered.api.item.ItemStack;
import org.sandboxpowered.api.item.Items;
import org.sandboxpowered.api.item.tool.ToolItem;
import org.sandboxpowered.api.item.tool.ToolMaterial;
import org.sandboxpowered.api.item.tool.ToolMaterials;
import org.sandboxpowered.api.item.tool.ToolType;
import org.sandboxpowered.api.registry.Registrar;
import org.sandboxpowered.api.state.BlockState;
import org.sandboxpowered.api.resources.ResourceConstants;
import org.sandboxpowered.api.resources.ResourceMaterial;
import org.sandboxpowered.api.resources.ResourceService;
import org.sandboxpowered.api.util.InteractionResult;
import org.sandboxpowered.api.util.math.Position;
import org.sandboxpowered.api.world.World;

public class Example implements Addon {
public static BlockEntity.Type<?> pipeEntityType;
import java.util.List;

public class Example implements Addon {
@Override
public void init(SandboxAPI api) {
api.getLog().info("Loading Example Addon");

BlockEvents.BREAK.subscribe((world, position, state, player, tool, cancellable) -> {
if (state.is(Blocks.BEDROCK))
cancellable.cancel();
});

ItemEvents.DRAW_STACK_COUNT.subscribe((stack, previous) -> {
return previous && !Items.DIAMOND.matches(stack.getItem());
});
ItemEvents.SHOW_DURABILITY_BAR.subscribe((stack, previous) -> {
return previous || Items.DIAMOND.matches(stack.getItem()) || stack.isDamageable();
});
ItemEvents.GET_DURABILITY_VALUE.subscribe((stack, previous) -> {
if (Items.DIAMOND.matches(stack.getItem()))
return stack.getCount() / (float) stack.getMaxCount();
return previous;
});
ItemEvents.GET_DURABILITY_COLOR.subscribe((stack, previous) -> {
if (Items.DIAMOND.matches(stack.getItem())) return 0x15CCEC;
return previous;
});

BlockEvents.INTERACT.subscribe((world, position, state, player, hand, stack, result) -> {
if (result != InteractionResult.IGNORE)
return result;
if (!stack.getItem().getIdentity().getPath().contains("shovel"))
return InteractionResult.IGNORE;
if(!state.is(Blocks.DIRT) || !world.getBlockState(position.up()).isAir())
if (world.isClient())
return InteractionResult.IGNORE;
if(world.isServer()) {
world.setBlockState(position, Blocks.GRASS_PATH.get());
stack.damage(1, player);
Block block = state.getBlock();
if (block instanceof CropBlock) {
CropBlock crop = (CropBlock) block;
int age = crop.getAge(state);
if (age >= crop.getMaxAge()) {
List<ItemStack> drops = block.getDrops(world, position, state);

boolean foundSeed = false;

for (ItemStack drop : drops) {
if (drop.isEmpty())
continue;

if (drop.getItem() == crop.getSeed()) {
drop.shrink(1);
foundSeed = true;
break;
}
}

if (foundSeed) {
if (world.isServer()) {
world.setBlockState(position, crop.stateForAge(0));
for (ItemStack drop : drops) {
world.spawnItem(position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5, drop);
}
}
return InteractionResult.SUCCESS;
}
}
}
return InteractionResult.SUCCESS;
return InteractionResult.IGNORE;
});
}

public void registerMaterials(ResourceService service) {
service.add(ResourceConstants.IRON, ResourceConstants.INGOT);
service.add(ResourceConstants.GOLD, ResourceConstants.INGOT);
service.add(ResourceConstants.COPPER,
ResourceConstants.INGOT,
ResourceConstants.ORE,
ResourceConstants.NUGGET,
ResourceConstants.BLOCK
);
}

@Override
public void register(Registrar registrar) {
PipeBlock pipe = new PipeBlock(Block.Settings.builder(Material.METAL).build());
pipeEntityType = BlockEntity.Type.of(() -> new PipeBlockEntity(pipeEntityType), pipe);
registrar.register("pipe", pipe);
registrar.register("pipe", pipeEntityType);
registrar.register("pipe", new BaseBlockItem(pipe, new Item.Settings()));
public void register(SandboxAPI api, Registrar registrar) {
registrar.useRegistrarService(ResourceService.class, this::registerMaterials);
registrar.register("test", new BaseItem(new Item.Settings()));
registrar.register("block", new BaseBlock(Block.Settings.builder(Materials.STONE).setLuminance(-1).build()));
registrar.register("block_no_itemblock", new BaseBlock(Block.Settings.builder(Materials.STONE).removeItemBlock().build()));

registrar.register("wooden_paxel", createPaxel(ToolMaterials.WOOD, 6.0F, -3.2F));
registrar.register("stone_paxel", createPaxel(ToolMaterials.STONE, 7.0F, -3.2F));
registrar.register("iron_paxel", createPaxel(ToolMaterials.IRON, 6.0F, -3.1F));
registrar.register("golden_paxel", createPaxel(ToolMaterials.GOLD, 6.0F, -3.0F));
registrar.register("diamond_paxel", createPaxel(ToolMaterials.DIAMOND, 5.0F, -3.0F));
registrar.register("netherite_paxel", createPaxel(ToolMaterials.NETHERITE, 5.0F, -3.0F));
}

public ToolItem createPaxel(ToolMaterial material, float damageIn, float speedIn) {
return new ToolItem(material, damageIn, speedIn, new Item.Settings()
.addToolTypes(material,
ToolType.PICKAXE,
ToolType.AXE,
ToolType.SHOVEL,
ToolType.STRIPPER,
ToolType.PAVER
)
);
}
}
115 changes: 0 additions & 115 deletions TestAddon/src/main/java/org/sandboxpowered/example/PipeBlock.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
package org.sandboxpowered.example;

import org.sandboxpowered.api.util.annotation.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"item.exampleaddon.wooden_paxel": "Wooden Paxel",
"item.exampleaddon.stone_paxel": "Stone Paxel",
"item.exampleaddon.iron_paxel": "Iron Paxel",
"item.exampleaddon.golden_paxel": "Golden Paxel",
"item.exampleaddon.diamond_paxel": "Diamond Paxel",
"item.exampleaddon.netherite_paxel": "Netherite Paxel"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"PSA",
" B ",
" # "
],
"key": {
"#": {
"item": "minecraft:stick"
},
"B": {
"item": "minecraft:slime_ball"
},
"P": {
"item": "minecraft:diamond_pickaxe"
},
"A": {
"item": "minecraft:diamond_axe"
},
"S": {
"item": "minecraft:diamond_shovel"
}
},
"result": {
"item": "exampleaddon:diamond_paxel"
}
}
Loading