import React, { useState } from 'react'; import { faMinus, faPlus } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { Accordion, Button, ButtonGroup, Card, Form, OverlayTrigger, Tooltip, } from 'react-bootstrap'; import WeightedTextEntry from '../modules/Config/WeightedTextEntry'; import ExtendableInput from '../modules/Config/ExtendableInput'; import ExtendableBiomeInput from '../modules/Config/ExtendableBiomeInput'; export default ({ mc114, idx, onEntryCreation, onEntryDeletion, onConfigChange, prefill, }) => { const [state, setState] = useState(prefill || { name: '', depType: 'deposit', type: 'dense', oreBlocks: null, // string or string[] depending on type sampleBlocks: null, // string or string[] depending on type maxY: 1, minY: 0, chance: 0, size: 1, density: 1, dimBlacklist: [], blockStateMatchers: [], // string[] }); const setStateWithPropogation = (newState) => { setState(newState); onConfigChange(idx, newState); }; return ( Config Entry {idx !== 0 && ( )}
Deposit Name [Optional] { setStateWithPropogation( { ...state, name: evt.target.value }, ); }} /> Deposit Type setStateWithPropogation( { ...state, depType: evt.target.value }, )} > {mc114 && ( Deposit Structure Type ( 1.14+ Only ) setStateWithPropogation( { ...state, type: evt.target.value }, )} > )} Ore Blocks { setStateWithPropogation({ ...state, oreBlocks }); }} /> Sample Blocks { setStateWithPropogation({ ...state, sampleBlocks }); }} /> Maximum Y-Level { const maxY = (state.maxY < state.minY) ? state.minY + 1 : parseInt(evt.target.value, 10); setStateWithPropogation({ ...state, maxY }); }} /> Minimum Y-Level { const minY = (state.minY > state.maxY) ? state.maxY - 1 : parseInt(evt.target.value, 10); setStateWithPropogation({ ...state, minY }); }} /> Chance ( Relative To All Chances {' '} ) setStateWithPropogation( { ...state, chance: parseInt(evt.target.value, 10) }, )} /> Size setStateWithPropogation( { ...state, size: parseInt(evt.target.value, 10) }, )} /> Density Any Decimal Between 0 and 1 )} > { if (evt.target.value > 1) { setStateWithPropogation( { ...state, density: 1 }, ); } else if (evt.target.value < 0) { setStateWithPropogation( { ...state, density: 0 }, ); } else { setStateWithPropogation( { ...state, density: Number(evt.target.value) }, ); } }} /> {state.depType.toLowerCase().includes('biome') && ( Biomes To Spawn / Not Spawn setStateWithPropogation({ ...state, ...wlState, })} /> )} Dimension Blacklist ' : 'Any Dimension ID (e.g. -1, 1)'} onChangeSuper={(dimBlacklist) => setStateWithPropogation( { ...state, dimBlacklist }, )} /> Blocks This Deposit May Replace setStateWithPropogation( { ...state, blockStateMatchers }, )} />
); };