Add Creative Energy Source
All checks were successful
EnergonRelics/pipeline/head This commit looks good
All checks were successful
EnergonRelics/pipeline/head This commit looks good
This commit is contained in:
parent
40ce3e75bd
commit
1981088444
@ -1,6 +1,7 @@
|
||||
package com.thebrokenrail.energonrelics;
|
||||
|
||||
import com.thebrokenrail.energonrelics.block.BlockBreakerBlock;
|
||||
import com.thebrokenrail.energonrelics.block.CreativeEnergySourceBlock;
|
||||
import com.thebrokenrail.energonrelics.block.DefensiveLaserBlock;
|
||||
import com.thebrokenrail.energonrelics.block.LightningRodBlock;
|
||||
import com.thebrokenrail.energonrelics.block.VeridiumBlockBlock;
|
||||
@ -89,6 +90,8 @@ public class EnergonRelics implements ModInitializer {
|
||||
private static final Identifier BEEP_SOUND_ID = new Identifier(NAMESPACE, "beep");
|
||||
private static final SoundEvent BEEP_SOUND_EVENT = new SoundEvent(BEEP_SOUND_ID);
|
||||
|
||||
public static final CreativeEnergySourceBlock CREATIVE_ENERGY_SOURCE_BLOCK = new CreativeEnergySourceBlock();
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
NETWORK_CHIP_ITEM = Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "network_chip"), new NetworkChipItem());
|
||||
@ -134,11 +137,13 @@ public class EnergonRelics implements ModInitializer {
|
||||
FORCEFIELD_PROJECTOR_BLOCK.register("forcefield_projector");
|
||||
|
||||
Registry.register(Registry.SOUND_EVENT, BEEP_SOUND_ID, BEEP_SOUND_EVENT);
|
||||
|
||||
CREATIVE_ENERGY_SOURCE_BLOCK.register("creative_energy_source");
|
||||
}
|
||||
|
||||
public static void playBeep(World world, BlockPos pos) {
|
||||
if (!world.isClient()) {
|
||||
world.playSound(null, pos, BEEP_SOUND_EVENT, SoundCategory.BLOCKS, 0.5f, 1f);
|
||||
world.playSound(null, pos, BEEP_SOUND_EVENT, SoundCategory.BLOCKS, 0.3f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.thebrokenrail.energonrelics.block;
|
||||
|
||||
import com.thebrokenrail.energonrelics.block.entity.CreativeEnergySourceBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.block.util.energy.EnergyProviderBlock;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class CreativeEnergySourceBlock extends EnergyProviderBlock {
|
||||
public CreativeEnergySourceBlock() {
|
||||
super(FabricBlockSettings.copy(Blocks.BEDROCK).dropsNothing());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<BlockEntityType<BlockEntity>, BlockEntity> getFactory() {
|
||||
return CreativeEnergySourceBlockEntity::new;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.thebrokenrail.energonrelics.block.entity;
|
||||
|
||||
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
||||
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
|
||||
import com.thebrokenrail.energonrelics.energy.helper.EnergyGeneratorBlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CreativeEnergySourceBlockEntity extends EnergyGeneratorBlockEntity {
|
||||
public CreativeEnergySourceBlockEntity(BlockEntityType<?> type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDisplayEnergy() {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnergyProviderBlockEntity> startTick() {
|
||||
setEnergy(getDisplayEnergy());
|
||||
return super.startTick();
|
||||
}
|
||||
}
|
@ -97,7 +97,7 @@ public class StructureGeneratorBlock extends SimpleBlockWithEntity {
|
||||
}
|
||||
|
||||
public void schedule(World world, BlockPos pos) {
|
||||
world.getBlockTickScheduler().schedule(pos, this, 4);
|
||||
world.getBlockTickScheduler().schedule(pos, this, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.thebrokenrail.energonrelics.energy.core.util;
|
||||
|
||||
import com.thebrokenrail.energonrelics.energy.core.EnergyProviderBlockEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EnergyTicker {
|
||||
private static final List<EnergyProviderBlockEntity> scheduled = new ArrayList<>();
|
||||
@ -13,7 +15,10 @@ public class EnergyTicker {
|
||||
scheduled.add(provider);
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
public static void tick(World world) {
|
||||
if (Objects.requireNonNull(world.getServer()).getThread() != Thread.currentThread()) {
|
||||
scheduled.clear();
|
||||
} else {
|
||||
List<EnergyProviderBlockEntity> started = new ArrayList<>();
|
||||
|
||||
List<EnergyProviderBlockEntity> temp = new ArrayList<>(scheduled);
|
||||
@ -35,4 +40,5 @@ public class EnergyTicker {
|
||||
provider.logicTick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public abstract class MixinWorld {
|
||||
@Inject(at = @At("TAIL"), method = "tickBlockEntities")
|
||||
public void tickBlockEntities(CallbackInfo info) {
|
||||
if (!isClient()) {
|
||||
EnergyTicker.tick();
|
||||
EnergyTicker.tick((World) (Object) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"variants": {
|
||||
"": {
|
||||
"model": "energonrelics:block/creative_energy_source"
|
||||
}
|
||||
}
|
||||
}
|
@ -36,5 +36,6 @@
|
||||
"item.minecraft.tipped_arrow.effect.energonrelics.veridium_poison": "Arrow of Degradation",
|
||||
"block.energonrelics.lightning_rod": "Lightning Rod",
|
||||
"block.energonrelics.forcefield": "Forcefield",
|
||||
"block.energonrelics.forcefield_projector": "Forcefield Projector"
|
||||
"block.energonrelics.forcefield_projector": "Forcefield Projector",
|
||||
"block.energonrelics.creative_energy_source": "Creative Energy Source"
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "minecraft:block/cube_all",
|
||||
"textures": {
|
||||
"all": "energonrelics:block/creative_energy_source"
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"parent": "energonrelics:block/creative_energy_source"
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 713 B |
Reference in New Issue
Block a user