Skip to content

Commit

Permalink
CE Fabric 1.2.1 Release
Browse files Browse the repository at this point in the history
Update to 1.20.4
Add GameRule
  • Loading branch information
Killarexe committed Dec 14, 2023
1 parent 1df7166 commit c81f3b4
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 18 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.23
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.2

mod_version=1.2
mod_version=1.2.1
maven_group=github.killarexe
archives_base_name=copper_extension

fabric_version=0.90.0+1.20.2
fabric_version=0.91.2+1.20.4
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package github.killarexe.copper_extension.common.item;

import github.killarexe.copper_extension.registry.CEGameRules;
import github.killarexe.copper_extension.registry.CEItems;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Entity.RemovalReason;
import net.minecraft.entity.ItemEntity;
Expand All @@ -13,7 +15,7 @@

public class RustableItem extends WaxableItem{

public static final float CHANCE = 0.0013666F;
public static final float BASE_CHANCE = 0.0013666F;

private final Identifier rustItemId;

Expand All @@ -24,14 +26,14 @@ public RustableItem(Settings settings, Identifier scrappedItemId, Identifier wax

@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if(entity instanceof PlayerEntity player) {
rustStack(stack, world.random, player, slot);
if(entity instanceof PlayerEntity player && !world.isClient()) {
rustStack(stack, world, player, slot);
}
}

public static void rustEntityStack(Item nextItem, ItemStack stack, World world, ItemEntity entity, Random random) {
int count = stack.getCount();
if(random.nextFloat() < CHANCE / count) {
if(random.nextFloat() < world.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * BASE_CHANCE / count) {
Vec3d pos = entity.getPos();
ItemEntity newItemEntity = new ItemEntity(world, pos.x, pos.y, pos.z, new ItemStack(nextItem, count));
newItemEntity.copyPositionAndRotation(entity);
Expand All @@ -40,8 +42,11 @@ public static void rustEntityStack(Item nextItem, ItemStack stack, World world,
}
}

private void rustStack(ItemStack stack, Random random, PlayerEntity player, int slot) {

private void rustStack(ItemStack stack, World world, PlayerEntity player, int slot) {
int count = stack.getCount();
if(world.random.nextFloat() < world.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * BASE_CHANCE / count) {
player.getInventory().setStack(slot, new ItemStack(CEItems.getItem(rustItemId), count));
}
}

public Identifier getRustItemId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ActionResult useOnBlock(ItemUsageContext context) {
ItemStack stack = context.getStack();
int amount = player.isSneaking() ? currentValue : 1;
waxStack(CEItems.getItem(waxedItemId), world, stack, playerPos, amount);
world.setBlockState(pos, state.with(BeehiveBlock.HONEY_LEVEL, currentValue - amount), Block.field_31022);
world.setBlockState(pos, state.with(BeehiveBlock.HONEY_LEVEL, currentValue - amount), Block.NOTIFY_ALL_AND_REDRAW);
return ActionResult.SUCCESS;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import github.killarexe.copper_extension.common.item.RustableItem;
import github.killarexe.copper_extension.common.item.WaxableItem;
import github.killarexe.copper_extension.registry.CEGameRules;
import github.killarexe.copper_extension.registry.CEItems;
import net.fabricmc.fabric.api.item.v1.FabricItem;
import net.minecraft.block.BeehiveBlock;
Expand All @@ -33,7 +34,7 @@ public abstract class ItemMixin implements ToggleableFeature, ItemConvertible, F
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected, CallbackInfo callbackInfo){
if(entity instanceof PlayerEntity player && stack.getItem() == Items.COPPER_INGOT) {
int count = stack.getCount();
if(player.getRandom().nextFloat() < RustableItem.CHANCE / count) {
if(player.getRandom().nextFloat() < world.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * RustableItem.BASE_CHANCE / count) {
player.getInventory().setStack(slot, new ItemStack(CEItems.EXPOSED_COPPER_INGOT, count));
}
}
Expand All @@ -53,7 +54,7 @@ public void useOnBlock(ItemUsageContext context, CallbackInfoReturnable<ActionRe
ItemStack stack = context.getStack();
int amount = player.isSneaking() ? currentValue : 1;
WaxableItem.waxStack(CEItems.WAXED_COPPER_INGOT, world, stack, playerPos, amount);
world.setBlockState(pos, state.with(BeehiveBlock.HONEY_LEVEL, currentValue - amount), Block.field_31022);
world.setBlockState(pos, state.with(BeehiveBlock.HONEY_LEVEL, currentValue - amount), Block.NOTIFY_ALL_AND_REDRAW);
callbackInfoReturnable.setReturnValue(ActionResult.SUCCESS);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package github.killarexe.copper_extension.registry;

import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
import net.minecraft.world.GameRules;

public class CEGameRules {
public static final GameRules.Key<GameRules.IntRule> COPPER_OXIDATION_CHANCE = GameRuleRegistry.register(
"copperOxidationChance", GameRules.Category.UPDATES, GameRuleFactory.createIntRule(1)
);

public static void register() {
//Just to load the class...
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class CERegistries {
public static void register() {
CEMod.LOGGER.debug("Initializing Copper Extension Items...");
CEGameRules.register();
CEItems.register();
CEMod.LOGGER.debug("Copper Extension Items Initialized!");
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/assets/copper_extension/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"item.copper_extension.waxed_copper_ingot": "Waxed Copper Ingot",
"item.copper_extension.waxed_exposed_copper_ingot": "Waxed Exposed Copper Ingot",
"item.copper_extension.waxed_weathered_copper_ingot": "Waxed Weathered Copper Ingot",
"item.copper_extension.weathered_copper_ingot": "Weathered Copper Ingot"
"item.copper_extension.weathered_copper_ingot": "Weathered Copper Ingot",
"gamerule.copperOxidationChance": "Copper oxidation chance"
}
3 changes: 2 additions & 1 deletion src/main/resources/assets/copper_extension/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"item.copper_extension.waxed_copper_ingot": "Lingot de cuivre ciré",
"item.copper_extension.waxed_exposed_copper_ingot": "Lingot de cuivre exposé et ciré",
"item.copper_extension.waxed_weathered_copper_ingot": "Lingot de cuivre érodé et ciré",
"item.copper_extension.weathered_copper_ingot": "Lingot de cuivre érodé"
"item.copper_extension.weathered_copper_ingot": "Lingot de cuivre érodé",
"gamerule.copperOxidationChance": "Chance d'érosion du cuivre"
}
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
}
],
"depends": {
"fabricloader": ">=0.14.21",
"minecraft": "~1.20.2",
"fabricloader": ">=0.15.2",
"minecraft": "~1.20.4",
"java": ">=17",
"fabric-api": "*"
},
Expand Down

0 comments on commit c81f3b4

Please sign in to comment.